From 57be7add681a5b055dbb1b096130691aebb5b74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 19 May 2020 09:23:48 +0200 Subject: [PATCH] Do not emit error as it closes the internal DB's connection stream and the Pool needs to keep it open to reuse the the connection --- lib/api/sql/copy-controller.js | 2 +- lib/services/stream-copy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/api/sql/copy-controller.js b/lib/api/sql/copy-controller.js index 68815ce9..b31f4da9 100644 --- a/lib/api/sql/copy-controller.js +++ b/lib/api/sql/copy-controller.js @@ -123,7 +123,7 @@ function handleCopyFrom (logger) { metrics.end(null, err); pgstream.emit('error', err); }) - .on('close', () => pgstream.emit('error', new Error('Connection closed by client'))) + .on('close', () => pgstream.emit('client-close', new Error('Connection closed by client'))) .pipe(throttle) .pipe(decompress) .on('data', data => { diff --git a/lib/services/stream-copy.js b/lib/services/stream-copy.js index 48e69f85..beb42518 100644 --- a/lib/services/stream-copy.js +++ b/lib/services/stream-copy.js @@ -56,7 +56,7 @@ module.exports = class StreamCopy { pgstream.on('warning', (msg) => this.logger.warn(msg)); } else if (action === ACTION_FROM) { pgstream.on('finish', () => done()); - pgstream.on('error', err => client.connection.sendCopyFail(err.message)); + pgstream.on('client-close', err => client.connection.sendCopyFail(err.message)); } pgstream.on('error', err => done(err));