diff --git a/app/controllers/copy_controller.js b/app/controllers/copy_controller.js index 6509c1ef..f4cd4216 100644 --- a/app/controllers/copy_controller.js +++ b/app/controllers/copy_controller.js @@ -113,6 +113,13 @@ function handleCopyTo (logger) { }) .on('end', () => responseEnded = true); + pgstream.on('error', (err) => { + metrics.end(null, err); + pgstream.unpipe(res); + + return next(err); + }); + pgstream .on('data', data => metrics.addSize(data.length)) .pipe(res);