diff --git a/lib/native/query.js b/lib/native/query.js index 9b1a730b..5436f02a 100644 --- a/lib/native/query.js +++ b/lib/native/query.js @@ -27,6 +27,7 @@ var NativeQuery = function(config, values, callback) { this._result = new Result(config.rowMode); this._addedFields = false; + this._hadError = false; //normalize values if(this.values) { for(var i = 0, len = this.values.length; i < len; i++) { @@ -55,6 +56,7 @@ NativeQuery.prototype.handleError = function(error) { error = this._canceledDueToError; this._canceledDueToError = false; } + this._hadError = true; if(this.callback) { var cb = this.callback; //remove callback to prevent double call on readyForQuery @@ -66,6 +68,7 @@ NativeQuery.prototype.handleError = function(error) { }; NativeQuery.prototype.handleReadyForQuery = function(meta) { + if(this._hadError) return; if (this._canceledDueToError) { return this.handleError(this._canceledDueToError); } diff --git a/test/integration/client/query-error-handling-tests.js b/test/integration/client/query-error-handling-tests.js index 030cd493..2b708b8d 100644 --- a/test/integration/client/query-error-handling-tests.js +++ b/test/integration/client/query-error-handling-tests.js @@ -20,7 +20,7 @@ test('error during query execution', function() { //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') + assert.fail('Query with an error should not emit "end" event') }) var client2 = new Client(helper.args); client2.connect(assert.success(function() {