From f16dee5df030d4690095817256945b749ffdecaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20=C5=BDaromskis?= Date: Tue, 4 Sep 2018 12:29:36 +0300 Subject: [PATCH 1/2] Reject query immediately if connection is being terminated --- lib/client.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/client.js b/lib/client.js index 0d023db7c..b339328b7 100644 --- a/lib/client.js +++ b/lib/client.js @@ -369,6 +369,13 @@ Client.prototype.query = function (config, values, callback) { } } + if (this._ending) { + if (query.callback) { + query.callback(new Error('Could not accept query, because connection has ended')) + } + return + } + if (this.binary && !query.binary) { query.binary = true } From e030f8430f01df6d1e6248ea1c0767ee646cd5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20=C5=BDaromskis?= Date: Wed, 5 Sep 2018 13:04:37 +0300 Subject: [PATCH 2/2] query() is expected to return a promise --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index b339328b7..cc655d5c1 100644 --- a/lib/client.js +++ b/lib/client.js @@ -373,7 +373,7 @@ Client.prototype.query = function (config, values, callback) { if (query.callback) { query.callback(new Error('Could not accept query, because connection has ended')) } - return + return result } if (this.binary && !query.binary) {