Listen to response events (on behalf of @oleurud)
This commit is contained in:
parent
0eab03a7e7
commit
332f7096d3
@ -14,6 +14,21 @@ module.exports = {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
let responseEnded = false;
|
||||
|
||||
res
|
||||
.on('error', err => {
|
||||
pgstream.unpipe(res);
|
||||
return cb(err);
|
||||
})
|
||||
.on('close', () => {
|
||||
if (!responseEnded) {
|
||||
|
||||
return cb(new Error('Connection closed by client'));
|
||||
}
|
||||
})
|
||||
.on('end', () => responseEnded = true);
|
||||
|
||||
const copyToStream = copyTo(sql);
|
||||
const pgstream = client.query(copyToStream);
|
||||
pgstream
|
||||
|
Loading…
Reference in New Issue
Block a user