Skip to content

Commit ae4d83f

Browse files
billywhizzaddaleax
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 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 59547cc commit ae4d83f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎lib/_http_client.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ function socketCloseListener() {
353353
varparser=socket.parser;
354354
if(req.res&&req.res.readable){
355355
// Socket closed before we emitted 'end' below.
356-
req.res.emit('aborted');
356+
if(!req.res.complete)req.res.emit('aborted');
357357
varres=req.res;
358358
res.on('end',function(){
359359
res.emit('close');

0 commit comments

Comments
 (0)