From e39a9b2bf75c0f58c1c1061672790660854a75a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Thu, 21 Jun 2018 13:13:37 +0200 Subject: [PATCH] copy to: manage error in 1 point --- app/controllers/copy_controller.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) 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); }); } );