-
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
[x] stream: eof & pipeline compat #29724
Conversation
5a1ac87
to
3fe9f39
Compare
ping @mafintosh |
617e410
to
ec1fb21
Compare
b1deba7
to
53e0fe6
Compare
92d3138
to
b2f52b5
Compare
bbba57c
to
9e9b654
Compare
Is this still relevant? Been stale for a while... Happy new year! |
rebased to fix conflicts |
CI |
ping @mafintosh |
Make stream.finished callback invoked if stream is already closed/destroyed.
PR-URL: nodejs#29664 Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Some broken streams might emit 'close' before 'end' or 'finish'. However, if they have actually been ended or finished, this should not result in a premature close error. Fixes: nodejs#29699
rebased to fix conflict |
Turns out this actually had a little bit of an issue, the stream might still be in a pending state after |
a858773
to
bfca3d1
Compare
This is still quite complex, but tried to do another pass at it. Can give an slight 👍. As mentioned in my comment I think it's worth investing in making a happy-path for when a stream is autoDestroy: true since that's much easier to reason about. |
Thx!
I'm not quite sure I understand what you mean by this? Something like the following? if (autoDestroy && emitClose) {
if (opts.error !== false) stream.on('error', onerror);
function onclose() {
callback.call(stream);
}
if (closed) {
process.nextTick(callback.bind(stream));
} else {
stream.on('close', onclose);
}
return () => {
stream.removeListener('close', onclose);
stream.removeListener('error', onerror);
};
}
// Rest is compat and edge cases... |
My general feeling is that landing this safely is uncertain due to the complexity of the changes and uncertainty of reviewers. There are actually several changes here that do not need to be directly related and could be split up. I'm closing this in favour of smaller on more specific PR's. Please let me know if there are any objections to this. |
Some broken streams might emit 'close' before 'end' or 'finish'. However, if they have actually been ended or finished, this should not result in a premature close error.
This fixes #29699 while still maintaining what could be considered correct behaviour.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes