Skip to content

Commit

Permalink
Not all "end" events have to be considered bogus connections
Browse files Browse the repository at this point in the history
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 brianc#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...
  • Loading branch information
Sandro Santilli committed Mar 14, 2014
1 parent fb491cf commit a3a1cc9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 1 addition & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
5 changes: 0 additions & 5 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
},
Expand Down

0 comments on commit a3a1cc9

Please sign in to comment.