From a3a1cc999c2f4db557c9c30654ffb8d3312eb4f7 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 14 Mar 2014 18:16:26 +0100 Subject: [PATCH] Not all "end" events have to be considered bogus connections Instead, consider receiving a premature stream end while a query is in progress as an error sign, bubbling up the error to the client level. Fixes the testsuite while still fixing my cases and possibly #458. The correct fix would be to provide a .validate method to the pooler, and expose a .validate method to the client and to the connection classes for that purpose... --- lib/client.js | 1 + lib/pool.js | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) 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); }); },