diff --git a/packages/pg-pool/index.js b/packages/pg-pool/index.js index 3e505f797..cc450339a 100644 --- a/packages/pg-pool/index.js +++ b/packages/pg-pool/index.js @@ -124,10 +124,9 @@ class Pool extends EventEmitter { } if (this.ending) { this.log('pulse queue on ending') - if (this._idle.length) { - this._idle.slice().map((item) => { - this._remove(item.client) - }) + for (let i = this._idle.length - 1; i >= 0; i--) { + const item = this._idle[i] + this._remove(item.client) } if (!this._clients.length) { this.ended = true