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

Commit 277dc50

Browse files
ubershmekelbrianc
authored andcommitted
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.
1 parent 6b2883d commit 277dc50

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class Pool extends EventEmitter {
196196
this.emit('error', err, client)
197197
}
198198

199-
this.log('connecting new client')
199+
this.log('checking client timeout')
200200

201201
// connection timeout logic
202202
let tid
@@ -215,19 +215,20 @@ class Pool extends EventEmitter {
215215

216216
this.log('connecting new client')
217217
client.connect((err) => {
218-
this.log('new client connected')
219218
if (tid) {
220219
clearTimeout(tid)
221220
}
222221
client.on('error', idleListener)
223222
if (err) {
223+
this.log('client failed to connect', err)
224224
// remove the dead client from our list of clients
225225
this._clients = this._clients.filter(c => c !== client)
226226
if (timeoutHit) {
227227
err.message = 'Connection terminated due to connection timeout'
228228
}
229229
cb(err, undefined, NOOP)
230230
} else {
231+
this.log('new client connected')
231232
client.release = release.bind(this, client)
232233
this.emit('connect', client)
233234
this.emit('acquire', client)

0 commit comments

Comments
 (0)