Skip to content

Commit a3a1cc9

Browse files
author
Sandro Santilli
committed
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...
1 parent fb491cf commit a3a1cc9

File tree

2 files changed

+1
-5
lines changed

2 files changed

+1
-5
lines changed

lib/client.js

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Client.prototype.connect = function(callback) {
177177
var disconnectError = new Error('Stream unexpectedly ended during query execution');
178178
self.activeQuery.handleError(disconnectError);
179179
self.activeQuery = null;
180+
self.emit('error', disconnectError);
180181
}
181182
self.emit('end');
182183
});

lib/pool.js

-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ var pools = {
3333
pool.destroy(client);
3434
});
3535

36-
// Remove client from pool on connection end
37-
client.on('end', function() {
38-
pool.destroy(client);
39-
});
40-
4136
return cb(null, client);
4237
});
4338
},

0 commit comments

Comments
 (0)