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

This commit is contained in:
Daniel García Aubert 2020-05-19 09:23:48 +02:00
parent 95a092bd83
commit 57be7add68
2 changed files with 2 additions and 2 deletions

View File

@ -123,7 +123,7 @@ function handleCopyFrom (logger) {
metrics.end(null, err); metrics.end(null, err);
pgstream.emit('error', 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(throttle)
.pipe(decompress) .pipe(decompress)
.on('data', data => { .on('data', data => {

View File

@ -56,7 +56,7 @@ module.exports = class StreamCopy {
pgstream.on('warning', (msg) => this.logger.warn(msg)); pgstream.on('warning', (msg) => this.logger.warn(msg));
} else if (action === ACTION_FROM) { } else if (action === ACTION_FROM) {
pgstream.on('finish', () => done()); 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)); pgstream.on('error', err => done(err));