Only call destroy on a client when it is not already being destroyed
Adds a check in the error listener on the client in the pool, to prevent calling destroy on a client when it is already being destroyed. Without this check, if an error occurs during the ending of the stream, such as a timeout, the client is never removed from the pool and weird things happen.
This commit is contained in:
parent
ac0d1c71c2
commit
1c17177369
@ -30,7 +30,13 @@ var pools = {
|
||||
//via the pg object and then removing errored client from the pool
|
||||
client.on('error', function(e) {
|
||||
pool.emit('error', e, client);
|
||||
|
||||
// If the client is already being destroyed, the error
|
||||
// occurred during stream ending. Do not attempt to destroy
|
||||
// the client again.
|
||||
if (!client._destroying) {
|
||||
pool.destroy(client);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove connection from pool on disconnect
|
||||
|
Loading…
Reference in New Issue
Block a user