copy to: manage error in 1 point

This commit is contained in:
Simon Martín 2018-06-21 13:13:37 +02:00
parent 1dac5355d1
commit e39a9b2bf7

View File

@ -89,17 +89,10 @@ function handleCopyTo (logger) {
.on('close', () => { .on('close', () => {
const err = new Error('Connection closed by client'); const err = new Error('Connection closed by client');
pgstream.emit('cancelQuery', err); pgstream.emit('cancelQuery', err);
pgstream.emit('error', err);
metrics.end(null, err);
pgstream.unpipe();
return next(err);
}) })
.on('error', err => { .on('error', err => {
metrics.end(null, err); pgstream.emit('error', err);
pgstream.unpipe();
return next(err);
}); });
} }
); );