From 277dc508daea03a8f6c0bcc3c534cab5b2501b12 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Fri, 4 May 2018 11:06:49 -0700 Subject: [PATCH] Clarifying pool connect logging (#73) Existing log code was outputting 'connecting new client' twice and saying 'new client connected', creating a false impression when an error (like a timeout) was present. --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 02c66f2d..ab74209f 100644 --- a/index.js +++ b/index.js @@ -196,7 +196,7 @@ class Pool extends EventEmitter { this.emit('error', err, client) } - this.log('connecting new client') + this.log('checking client timeout') // connection timeout logic let tid @@ -215,12 +215,12 @@ class Pool extends EventEmitter { this.log('connecting new client') client.connect((err) => { - this.log('new client connected') if (tid) { clearTimeout(tid) } client.on('error', idleListener) if (err) { + this.log('client failed to connect', err) // remove the dead client from our list of clients this._clients = this._clients.filter(c => c !== client) if (timeoutHit) { @@ -228,6 +228,7 @@ class Pool extends EventEmitter { } cb(err, undefined, NOOP) } else { + this.log('new client connected') client.release = release.bind(this, client) this.emit('connect', client) this.emit('acquire', client)