From 8a76df88844460a07eef03c647f5e0d7c3df4cb4 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Fri, 10 Aug 2018 12:37:49 +0200 Subject: [PATCH] Fix for unhandled gunzip/zlib errors #528 --- app/controllers/copy_controller.js | 8 ++++---- test/acceptance/copy-endpoints.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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();