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: revert #14024 writable is never set to false #15404

Closed
wants to merge 1 commit into from

Conversation

mcollina
Copy link
Member

Setting writable = false in IncomingMessage.end made some errors
being swallowed in some very popular OSS libraries that we must
support. This commit add some of those use cases, so we avoid further
regressions.

See: #14024
Fixes: #15029

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

http

@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Sep 14, 2017
@mcollina
Copy link
Member Author

@mafintosh
Copy link
Member

awesome!

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

It would likely make sense to have a known issue test that covers the fix that is being reverted and includes an explanation as to why it is problematic.

@mcollina
Copy link
Member Author

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM with a comment.

external.abort();
res.end('Hello World\n');
}));
}).listen(3000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you write this test without hard coded port numbers.

@mscdex
Copy link
Contributor

mscdex commented Sep 14, 2017

I'm not really convinced this should be reverted. How are users expected to know whether we can safely call .write()/.end(foo) now, given an arbitrary response object? Reach into ._writableState?

@jasnell
Copy link
Member

jasnell commented Sep 14, 2017

This should be reverted because the change broke a userland module that has over 10 million downloads a month. That's not to say the reversion should be permanent, just that we should take a step back and look at another way of addressing the issue that isn't so breaking.

@mcollina
Copy link
Member Author

mcollina commented Sep 14, 2017

@mscdex this does not relate to Writable, it's on ServerResponse, which does inherit from Stream directly. This is the source of the problem. Making it inheriting from Writable would slow things down by 50% (at least), so that is out of the equation.

Part of the problem is that this is defined as a "legacy stream", and access to _writableState  and _readableState is currently used to know how a stream should behave. ServerResponse is missing that state, so we cannot really know what happened.

I'm definitely 👍 for a fix, but this should be reverted before 8 goes to LTS - and we should figure out how we can make ServerResponse more inspectable. These are the relevant lines:

https://github.com/mafintosh/end-of-stream/blob/master/index.js#L24-L26
https://github.com/mafintosh/end-of-stream/blob/master/index.js#L56-L59

I have tried to pursue a different fix for this for more than a month. I could not find a way to keep this in and not break the ecosystem (or our unit tests) in a semver-major way.

@mcollina
Copy link
Member Author

@mcollina
Copy link
Member Author

mcollina commented Sep 19, 2017

CI failures are unrelated.

CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/990/

cc @refack

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.

Maybe add a comment that we should look into this again as it is not desired behavior?

Setting writable = false in IncomingMessage.end made some errors
being swallowed in some very popular OSS libraries that we must
support. This commit add some of those use cases to the tests,
so we avoid further regressions.
We should reevaluate how to set writable = false in IncomingMessage
in a way that does not break the ecosystem.

See: nodejs#14024
Fixes: nodejs#15029
@mcollina
Copy link
Member Author

@BridgeAR I've added that in the commit message.

@mcollina
Copy link
Member Author

Landed as 8589c70.

@mcollina mcollina closed this Sep 20, 2017
@mcollina mcollina deleted the fix-15029 branch September 20, 2017 09:41
mcollina added a commit that referenced this pull request Sep 20, 2017
Setting writable = false in IncomingMessage.end made some errors
being swallowed in some very popular OSS libraries that we must
support. This commit add some of those use cases to the tests,
so we avoid further regressions.
We should reevaluate how to set writable = false in IncomingMessage
in a way that does not break the ecosystem.

See: #14024
Fixes: #15029
PR-URL: #15404
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
jasnell pushed a commit that referenced this pull request Sep 20, 2017
Setting writable = false in IncomingMessage.end made some errors
being swallowed in some very popular OSS libraries that we must
support. This commit add some of those use cases to the tests,
so we avoid further regressions.
We should reevaluate how to set writable = false in IncomingMessage
in a way that does not break the ecosystem.

See: #14024
Fixes: #15029
PR-URL: #15404
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@mcollina mcollina mentioned this pull request Sep 21, 2017
2 tasks
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
Setting writable = false in IncomingMessage.end made some errors
being swallowed in some very popular OSS libraries that we must
support. This commit add some of those use cases to the tests,
so we avoid further regressions.
We should reevaluate how to set writable = false in IncomingMessage
in a way that does not break the ecosystem.

See: nodejs/node#14024
Fixes: nodejs/node#15029
PR-URL: nodejs/node#15404
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Qard pushed a commit to Qard/ayo that referenced this pull request Sep 21, 2017
Setting writable = false in IncomingMessage.end made some errors
being swallowed in some very popular OSS libraries that we must
support. This commit add some of those use cases to the tests,
so we avoid further regressions.
We should reevaluate how to set writable = false in IncomingMessage
in a way that does not break the ecosystem.

See: nodejs/node#14024
Fixes: nodejs/node#15029
PR-URL: nodejs/node#15404
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
mcollina added a commit to mcollina/node that referenced this pull request Sep 27, 2017
mcollina added a commit that referenced this pull request Sep 27, 2017
Ref: #15404
Fixes: #15505
PR-URL: #15520
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit to MylesBorins/node that referenced this pull request Sep 28, 2017
Ref: nodejs#15404
Fixes: nodejs#15505
PR-URL: nodejs#15520
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Sep 29, 2017
Ref: #15404
Fixes: #15505
PR-URL: #15520
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 30, 2017
Ref: nodejs/node#15404
Fixes: nodejs/node#15505
PR-URL: nodejs/node#15520
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request Oct 3, 2017
Ref: #15404
Fixes: #15505
PR-URL: #15520
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Contributor

setting as dont-land-on-v6.x as the original never landed in a release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible bug in streams between node 8.1.4 and 8.2.0
8 participants