diff --git a/app/controllers/copy_controller.js b/app/controllers/copy_controller.js index 25bd85cb..f1ba507c 100644 --- a/app/controllers/copy_controller.js +++ b/app/controllers/copy_controller.js @@ -115,16 +115,16 @@ function handleCopyFrom (logger) { req .on('data', data => isGzip ? metrics.addGzipSize(data.length) : undefined) - .on('error', err => { - metrics.end(null, err); - pgstream.emit('error', err); - }) .on('close', () => { const err = new Error('Connection closed by client'); pgstream.emit('cancelQuery', err); pgstream.emit('error', err); }) .pipe(isGzip ? zlib.createGunzip() : new PassThrough()) + .on('error', err => { + metrics.end(null, err); + pgstream.emit('error', err); + }) .on('data', data => { metrics.addSize(data.length); diff --git a/test/acceptance/copy-endpoints.js b/test/acceptance/copy-endpoints.js index 13d639d4..4aa63cbb 100644 --- a/test/acceptance/copy-endpoints.js +++ b/test/acceptance/copy-endpoints.js @@ -203,7 +203,7 @@ describe('copy-endpoints', function() { assert.deepEqual( JSON.parse(res.body), { - error:["Error while decompressing: incorrect header check"] + error:["incorrect header check"] } ); done();