mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
parent
c3f5c06c44
commit
357b64d704
@ -93,11 +93,9 @@ Query.prototype.handleError = function(err, connection) {
|
||||
//if callback supplied do not emit error event as uncaught error
|
||||
//events will bubble up to node process
|
||||
if(this.callback) {
|
||||
this.callback(err);
|
||||
} else {
|
||||
this.emit('error', err);
|
||||
return this.callback(err);
|
||||
}
|
||||
this.emit('end');
|
||||
this.emit('error', err);
|
||||
};
|
||||
|
||||
Query.prototype.submit = function(connection) {
|
||||
|
||||
@ -12,10 +12,16 @@ test('error during query execution', function() {
|
||||
pidColName = 'pid';
|
||||
queryColName = 'query';
|
||||
}
|
||||
client.query(sleepQuery, assert.calls(function(err, result) {
|
||||
var query1 = client.query(sleepQuery, assert.calls(function(err, result) {
|
||||
assert(err);
|
||||
client.end();
|
||||
}));
|
||||
//ensure query1 does not emit an 'end' event
|
||||
//because it was killed and received an error
|
||||
//https://github.com/brianc/node-postgres/issues/547
|
||||
query1.on('end', function() {
|
||||
assert.fail('Client with an error should not emit "end" event')
|
||||
})
|
||||
var client2 = new Client(helper.args);
|
||||
client2.connect(assert.success(function() {
|
||||
var killIdleQuery = "SELECT " + pidColName + ", (SELECT pg_terminate_backend(" + pidColName + ")) AS killed FROM pg_stat_activity WHERE " + queryColName + " = $1";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user