Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: fix res emit close before user finish #20941

Closed
wants to merge 1 commit into from

Conversation

ronag
Copy link
Member

@ronag ronag commented May 24, 2018

Fixes a regression caused by #20611 which breaks eos, pump and pumpify.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label May 24, 2018
@ronag
Copy link
Member Author

ronag commented May 24, 2018

@jasnell @trivikr This is potentially urgent for a 10.2.1?

@ronag
Copy link
Member Author

ronag commented May 24, 2018

Another possible solution is to use prefinish instead of finish for resOnFinish but I'm unsure about the ramifications of that. This solution is safer.

@mafintosh
Copy link
Member

@ronag Thanks for the quick fix :)

@mafintosh
Copy link
Member

This is def urgent for a 10.2.1 - without this fix end-of-stream, pump and most userland stream stuff using those are broken when using http streams

@@ -562,7 +562,7 @@ function resOnFinish(req, res, socket, state, server) {

res.detachSocket(socket);
req.emit('close');
res.emit('close');
process.nextTick(emitCloseNT.bind(res));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also do process.nextTick(emitCloseNT, res) to avoid the bind and accept res as an arg in your emitCloseNT function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be better.

@jasnell
Copy link
Member

jasnell commented May 24, 2018

/cc @MylesBorins

@mafintosh
Copy link
Member

@jasnell jasnell added the fast-track PRs that do not need to wait for 48 hours to land. label May 24, 2018
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina
Copy link
Member

+1 to fast tracking.

res.on('finish', common.mustCall((() => {
assert.strictEqual(resClosed, false);
})));
res.on('close', common.mustCall((() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have an unneeded paran around the arrow fn here which the linter complains about

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if everything else is green I'll go ahead and fix that while landing

@ronag ronag force-pushed the fix-http-req-res-close-state branch from 0119e3a to a07ea85 Compare May 24, 2018 15:50
@ronag
Copy link
Member Author

ronag commented May 24, 2018

Fixed comments.

@jasnell
Copy link
Member

jasnell commented May 24, 2018

The other fix for 10.2.1 has been landed. As soon as this one lands we should be ready to go for 10.2.1

@MylesBorins
Copy link
Contributor

Kicked off another CI based on new changes

https://ci.nodejs.org/job/node-test-commit/18750/

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but the comment should be addressed (it could also be removed while landing).

})));
res.on('close', common.mustCall(() => {
resClosed = true;
// assert.strictEqual(res._writableState.ended, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented code.

@MylesBorins
Copy link
Contributor

The failures on arm will all infra related. I've fixed the linting error and removed comment when landing.

landed in 8ce20af

MylesBorins pushed a commit that referenced this pull request May 24, 2018
PR-URL: #20941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins pushed a commit that referenced this pull request May 24, 2018
PR-URL: #20941
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@MylesBorins MylesBorins mentioned this pull request May 24, 2018
@mafintosh
Copy link
Member

Thanks everyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fast-track PRs that do not need to wait for 48 hours to land. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants