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));