-
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
Writeable stream .end() has paradoxical logic #5540
Comments
cc @nodejs/streams |
I would say send a PR and we'll evaluate how many modules break :/. However all the writes and ends callbacks may not fire (as of now). This definitely improves the situation, but it's not the full solution. |
That logic in endWritable actually has to do with whether finishMaybe was able to finish the stream up or whether their were still pending async things. This will actually only come up if end is called without any data, if it's called with data then it will through an error. In theory yes having it through an error would be good, it would be a breaking change which would likely be bad. |
ping @nodejs/streams |
I will put this into our next wg meeting agenda. So that we can decide what's the right path. |
I think the problem here is that the callback to |
Should this remain open? |
Yes, I think so. |
Ideally we would love to fix it, but it will cause too much breakages at this point in a lot of modules. You can use http://npm.im/pump or https://www.npmjs.com/package/end-of-stream to know if a stream has ended. We are porting those over in #13506. cc @nodejs/streams |
It says here to ignore unnecessary end() calls. That means callbacks will not fire, even though end() is called. Should it not instead return either an error to the callback, or act as a noop before calling cb? The irony is that endWritable itself seems to act exactly like it may be called multiple times.
So which should it be? Right now, it seems like we have 2 different pieces of reasoning in the same class, and one simply overrules the other. Imho, we should get rid of one, and in my opinion, it should be the "ignore unnecessary end() calls" one, because when people pass a callback, they expect it to be called.
The text was updated successfully, but these errors were encountered: