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', () => {
const err = new Error('Connection closed by client');
pgstream.emit('cancelQuery', err);
metrics.end(null, err);
pgstream.unpipe();
return next(err);
pgstream.emit('error', err);
})
.on('error', err => {
metrics.end(null, err);
pgstream.unpipe();
return next(err);
pgstream.emit('error', err);
});
}
);