diff --git a/lib/client.js b/lib/client.js index 490e1d183..da8686d18 100644 --- a/lib/client.js +++ b/lib/client.js @@ -177,6 +177,7 @@ Client.prototype.connect = function(callback) { var disconnectError = new Error('Stream unexpectedly ended during query execution'); self.activeQuery.handleError(disconnectError); self.activeQuery = null; + self.emit('error', disconnectError); } self.emit('end'); }); diff --git a/lib/pool.js b/lib/pool.js index dec450ef7..9cf9aabf0 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -33,11 +33,6 @@ var pools = { pool.destroy(client); }); - // Remove client from pool on connection end - client.on('end', function() { - pool.destroy(client); - }); - return cb(null, client); }); },