http: prevent aborted event when already completed
When socket is closed on a response for a request that is being piped to a stream there is a condition where aborted event will be fired to http client when socket is closing and the incomingMessage stream is still set to readable. We need a check for request being complete and to only raise the 'aborted' event on the http client if we have not yet completed reading the response from the server. Fixes: https://github.com/nodejs/node/issues/18756 PR-URL: https://github.com/nodejs/node/pull/18999 Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
abd0d79304
commit
1980a36dd4
@ -321,7 +321,7 @@ function socketCloseListener() {
|
||||
var parser = socket.parser;
|
||||
if (req.res && req.res.readable) {
|
||||
// Socket closed before we emitted 'end' below.
|
||||
req.res.emit('aborted');
|
||||
if (!req.res.complete) req.res.emit('aborted');
|
||||
var res = req.res;
|
||||
res.on('end', function() {
|
||||
res.emit('close');
|
||||
|
Loading…
x
Reference in New Issue
Block a user