From 9d2c977ce9b13f8f3b024759b1deaec165564a6a Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Wed, 23 Jun 2021 02:55:21 +1200 Subject: [PATCH] Use _isFull instead of duplicating clients check (#2539) Noticed that options.max is compared against client count directly, but there's a method wrapping it. I can't see any reason to duplicate it? And using _isFull means I can override that for the adaptive pooling idea I'm exploring :) --- packages/pg-pool/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pg-pool/index.js b/packages/pg-pool/index.js index 780f1865..403d05a1 100644 --- a/packages/pg-pool/index.js +++ b/packages/pg-pool/index.js @@ -168,7 +168,7 @@ class Pool extends EventEmitter { const result = response.result // if we don't have to connect a new client, don't do so - if (this._clients.length >= this.options.max || this._idle.length) { + if (this._isFull() || this._idle.length) { // if we have idle clients schedule a pulse immediately if (this._idle.length) { process.nextTick(() => this._pulseQueue())