Skip to content

Commit be73773

Browse files
committed
Merge pull request brianc#620 from Jarvix/timeout_error_fix
Pool: Only call destroy on a client when it is not already being destroyed
2 parents 3d4ae51 + 1c17177 commit be73773

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/pool.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ var pools = {
3030
//via the pg object and then removing errored client from the pool
3131
client.on('error', function(e) {
3232
pool.emit('error', e, client);
33-
pool.destroy(client);
33+
34+
// If the client is already being destroyed, the error
35+
// occurred during stream ending. Do not attempt to destroy
36+
// the client again.
37+
if (!client._destroying) {
38+
pool.destroy(client);
39+
}
3440
});
3541

3642
// Remove connection from pool on disconnect

0 commit comments

Comments
 (0)