diff --git a/app/controllers/copy_controller.js b/app/controllers/copy_controller.js index 1642c202..83a1f312 100644 --- a/app/controllers/copy_controller.js +++ b/app/controllers/copy_controller.js @@ -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); }); } );