http: response should always emit close on finish#20043
http: response should always emit close on finish#20043trivikr wants to merge 2 commits intonodejs:masterfrom
Conversation
|
Rerun for node-test-commit-freebsd https://ci.nodejs.org/job/node-test-commit-freebsd/17043/ |
lib/_http_client.js
Outdated
| if (res) { | ||
| if (res.readable) { | ||
| // Socket closed before we emitted 'end' below. | ||
| res.emit('aborted'); |
There was a problem hiding this comment.
The !req.res.complete condition is gone, is this wanted?
There was a problem hiding this comment.
Is there any edit required here?
There was a problem hiding this comment.
It should have if (!req.res.complete) req.res.emit('aborted');. I would check the rest too. There have been changes to that part of code since that original PR was started.
lib/_http_client.js
Outdated
| if (!req.res.complete) req.res.emit('aborted'); | ||
| var res = req.res; | ||
| res.on('end', function() { | ||
| var res = req.res; |
|
This will need CITGM run and also, if we don't have something like |
|
I think we need to handle the if (res) {
// *******
// NOTE: if `req.emit('response')` has been emitted we must always emit `aborted`, regardless of whether the response is readable or not.
// Socket closed before we emitted 'end' below.
if (!res.complete) {
res.emit('aborted');
}
// *******
if (res.readable) {
res.on('end', function() {
res.emit('close');
});
res.push(null);
} else {
res.emit('close');
}
} |
|
Should we make the order of This would avoid intermittent bugs in code that depend on the order. if (res) {
if (res.readable) {
// Socket closed before we emitted 'end' below.
if (!res.complete) {
res.emit('aborted');
}
req.emit('close'); // !! Emit close before or after aborted?
res.on('end', function() {
res.emit('close');
});
res.push(null);
} else {
req.emit('close'); // !!
res.emit('close');
}
} else if (!req.socket._hadError) {
// This socket error fired before we started to
// receive a response. The error needs to
// fire on the request.
req.socket._hadError = true;
req.emit('error', createHangUpError());
req.emit('close'); // !!
} else {
req.emit('close'); // !!
} |
|
#20075, feel free to cherry-pick |
|
Ping @trivikr |
Fixes: #17352
Original PR was posted at #17397
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes