Skip to content

Commit ff6eab7

Browse files
committed
Merge pull request brianc#843 from oliversalzburg/fix/econnreset
Don't emit error events parsed out of data stream
2 parents 715e500 + e5a63ab commit ff6eab7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/pool.js

+5
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ var pools = {
2323
log: clientConfig.poolLog || defaults.poolLog,
2424
create: function(cb) {
2525
var client = new pools.Client(clientConfig);
26+
// Ignore errors on pooled clients until they are connected.
27+
client.on('error', Function.prototype);
2628
client.connect(function(err) {
2729
if(err) return cb(err, null);
2830

31+
// Remove the noop error handler after a connection has been established.
32+
client.removeListener('error', Function.prototype);
33+
2934
//handle connected client background errors by emitting event
3035
//via the pg object and then removing errored client from the pool
3136
client.on('error', function(e) {

test/unit/pool/basic-tests.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@ test('pool with connection error on connection', function() {
121121
process.nextTick(function() {
122122
cb(new Error('Could not connect'));
123123
});
124-
}
124+
},
125+
on: Function.prototype
125126
};
126-
}
127+
};
127128
test('two parameters', function() {
128129
var p = pools.getOrCreate(poolId++);
129130
p.connect(assert.calls(function(err, client) {

0 commit comments

Comments
 (0)