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 6e984e112..8532ee4cb 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()