From 4fc6e57709fac3db8db7e2e8fec17bff31796ba8 Mon Sep 17 00:00:00 2001 From: Peter Boromissza Date: Fri, 3 Nov 2017 16:01:14 +0100 Subject: [PATCH] Do not return broken connections to the idle pool --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index af86134..392c346 100644 --- a/index.js +++ b/index.js @@ -24,7 +24,7 @@ function throwOnRelease () { function release (client, err) { client.release = throwOnRelease - if (err || this.ending) { + if (err || this.ending || client._do_not_return_) { this._remove(client) this._pulseQueue() return @@ -181,6 +181,7 @@ class Pool extends EventEmitter { this.log('additional client error after disconnection due to error', err) }) this._remove(client) + client._do_not_return_ = true; // TODO - document that once the pool emits an error // the client has already been closed & purged and is unusable this.emit('error', err, client)