Handle error when client disconnects in copyto requests

This commit is contained in:
Daniel García Aubert 2018-06-13 19:54:34 +02:00
parent 6aba1ea307
commit e6a331433a

View File

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