From 57bd1441c26e3889bb9e4fc72c6e9ae0dcf6cfb3 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Wed, 15 Nov 2017 04:51:32 -0800 Subject: [PATCH] Mark clients with closed connections as unusable consistently --- lib/client.js | 4 ++-- test/integration/connection-pool/error-tests.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 411f743cf..9653f7dcc 100644 --- a/lib/client.js +++ b/lib/client.js @@ -208,10 +208,10 @@ Client.prototype.connect = function (callback) { if (callback) { callback(error) } else { - this.emit('error', error) + connectedErrorHandler(error) } } else if (!this._connectionError) { - this.emit('error', error) + connectedErrorHandler(error) } } this.emit('end') diff --git a/test/integration/connection-pool/error-tests.js b/test/integration/connection-pool/error-tests.js index 253f85a7a..4d7bb9c1f 100644 --- a/test/integration/connection-pool/error-tests.js +++ b/test/integration/connection-pool/error-tests.js @@ -60,7 +60,7 @@ suite.test('connection-level errors cause queued queries to fail', (cb) => { })) client.query('SELECT 1', assert.calls((err) => { - assert.equal(err.code, 'EPIPE') + assert.equal(err.message, 'Connection terminated unexpectedly') done() pool.end()