Skip to content

Commit c4fa1f7

Browse files
billywhizzMylesBorins
authored andcommitted
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: #18756 Backport-PR-URL: #22380 PR-URL: #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>
1 parent 02ea033 commit c4fa1f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/_http_client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ function socketCloseListener() {
350350
req.emit('close');
351351
if (req.res && req.res.readable) {
352352
// Socket closed before we emitted 'end' below.
353-
req.res.emit('aborted');
353+
if (!req.res.complete) req.res.emit('aborted');
354354
var res = req.res;
355355
res.on('end', function() {
356356
res.emit('close');

0 commit comments

Comments
 (0)