diff --git a/lib/Pool.js b/lib/Pool.js index f60a70e6..54b02f2c 100644 --- a/lib/Pool.js +++ b/lib/Pool.js @@ -302,11 +302,18 @@ class Pool extends EventEmitter { */ _ensureMinimum () { if (this._draining === true) { - return + return; + } + const minShortfall = this._config.min - this._count; + + if(minShortfall == 0){ + const waiting = this._waitingClientsQueue.size(); + if(waiting > 0){ + minShortFall = diff = Math.min(waiting, this._config.max - this._count); + } } - const minShortfall = this._config.min - this._count for (let i = 0; i < minShortfall; i++) { - this._createResource() + this._createResource(); } }