Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

Commit

Permalink
Clarifying pool connect logging (#73)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ubershmekel authored and brianc committed May 4, 2018
1 parent 6b2883d commit 277dc50
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -215,19 +215,20 @@ 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) {
err.message = 'Connection terminated due to connection timeout'
}
cb(err, undefined, NOOP)
} else {
this.log('new client connected')
client.release = release.bind(this, client)
this.emit('connect', client)
this.emit('acquire', client)
Expand Down

0 comments on commit 277dc50

Please sign in to comment.