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.
This commit is contained in:
Yuval Greenfield 2018-05-04 11:06:49 -07:00 committed by Brian C
parent 6b2883d290
commit 277dc508da

View File

@ -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)