mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
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:
parent
6b2883d290
commit
277dc508da
5
index.js
5
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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user