-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
eos and pipeline will deadlock if streams are not in assumed state #28650
Comments
I would suggest that |
This was fixed in a PR |
👋 Hi, @ronag do you happen to remember the PR that was supposed to fix this issue? I think I'm encountering the same issue, for which I've created a minimal reproduction. const { finished, PassThrough, pipeline } = require('stream');
const http = require('http');
const server = http.createServer((req, res) => {
console.log('server: request received');
const body = new PassThrough().end('foo');
setTimeout(() => {
console.log('server: pipeline begin');
return pipeline(body, res, (err) => {
console.log('server: pipeline end');
if (err) {
console.error('server: pipeline err:', err);
}
});
}, 100);
});
server.listen({ host: '127.0.0.1', port: 0 }, (err) => {
const addr = server.address();
const uri = `http://${addr.address}:${addr.port}`;
const req = http.request(uri).end();
req.on('response', async (res) => {
console.log('response received');
for await (const chunk of res) {
console.log('client: body: ', chunk.toString());
}
console.log('closing server');
server.close(() => {
console.log('server closed');
});
});
finished(req, (err) => {
console.log('client: end');
if (err) {
console.error('client: error: ', err);
}
});
// aborted request will cause server pipeline to never complete
setTimeout(() => req.abort(), 50);
}); Without the
With the
I get the same behavior on node versions 10, 12 and 13. Is this the expected behavior? If so, can you point me in the right direction on how this should be handled on the server side? cc @mcollina |
It will be included in Node 14 |
Currently,
pipeline
andeos
does not take into account whether the streams are "valid" or not to begin with.Consider this potentially common example:
or less common
This will fail... even though I believe it should error with a premature close (or something similar)?
Basically
eos
andpipeline
makes assumptions of the arguments which are not enforced...The text was updated successfully, but these errors were encountered: