-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Possible bug in streams between node 8.1.4 and 8.2.0 #15029
Comments
@nodejs/streams |
Is this #14024? |
That seems like a good candidate. |
Our code for this particular case is really hairy, so if it was an actual bug, and the fix is backported to 6, I'll with great joy remove our current handling of it 🙂 |
Can you please verify with 8.4.0? |
8.2.0, 8.2.1, 8.3.0 and 8.4.0 all behave the same |
6.11.2, 7.11.1, 8.0.0, 8.1.0 and 8.1.4 also behave the same, FWIW. So something changed between 8.1.4 and 8.2.0 |
So fare I see: Under the hood, pump uses end-of-stream. In version 8.1.4 and older end-of-stream get a |
I think the bug is more subtle than this. I would like not to revert #14024, and figure out what events changed. Can you reproduce the bug without Express and got? |
I've pushed usage of request instead of fetch. Never used got (it's get from http). Can look into removing express on Monday |
I meant, can you just show this using node core? |
@mcollina I've reduced the example down to just |
Here is a stipped down version: const { get, createServer } = require('http');
let external;
// Http server
createServer((req, res) => {
res.writeHead(200);
setTimeout(() => {
external.abort();
res.end('Hello World\n');
}, 1000);
}).listen(3000);
// Proxy server
createServer((req, res) => {
get('http://127.0.0.1:3000', inner => {
res.on('close', () => {
console.log('response writable:', res.writable);
});
inner.pipe(res);
});
}).listen(3001, () => {
external = get('http://127.0.0.1:3001');
}); What happens here is that we ( If one run the above in node 8.1.4 or older, In other words; in node 8.1.4 and older it seems like the writable response stream was writable after a To me this looks like a fixed bug in node 8.2.0 and not a new bug. What make it looks like a bug is that libraries such as end-of-stream and pump suddenly stopped providing error objects on the above scenario between two versions of node. If anyone can confirm that the above behaviour is correct (the response should not be writable after a close event), I'll be happy to report this to end-of-stream and pump so they can account for this change between the node versions. |
This is a result of #14024 which went into 8.2.0. This issue can be closed. |
Feel free to close if our analysis is correct (and the change in behavior is intended) |
Is there a way we can keep the existing behavior of pump and eos, and keep this change in? I'm a bit lost on the Error issue: why the Error is not bubbling up? |
FWIW I think this new behavior is correct, and the error vi got from Although it might be expected to get an error of some sort ( |
The stream are terminated prematurelly in all versions. In node 8.1.4 and older I am not sure how |
@trygve-lie I understand the problem now. I think it's a bug in core. |
I was absolutely wrong in what I said. What's happening is clear to me, but not how to fix this and maintain #14024. I'll be reverting that asap. |
Reverting #14024 and revisiting it later looks like the only viable path forward on this. |
I'm curios, could you expand on that? EDIT: Done in #15404 (comment), so no need to do so here. Thanks! |
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
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>
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>
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>
We have some code which uses
pump
, and between 8.1.4 and 8.2.0 the handler in certain cases stopped being called with an error. We have a test that our error handler is invoked correctly, which fails on newer versions of node.In 8.1.4 we hit https://github.com/mafintosh/end-of-stream/blob/0ae1658b8167596fafbb9195363ada3bc5a3eaf2/index.js#L44, whilst in 8.2.0 (and later) we don't.
I've created a repository with reproduction code.
https://github.com/SimenB/node-stream-repro
The text was updated successfully, but these errors were encountered: