Fix for unhandled gunzip/zlib errors #528

This commit is contained in:
Rafa de la Torre 2018-08-10 12:37:49 +02:00
parent 6193f58dd2
commit 8a76df8884
2 changed files with 5 additions and 5 deletions

View File

@ -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);

View File

@ -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();