-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
streams: pipeline error if any stream is destroyed #36791
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
streams: pipeline error if any stream is destroyed #36791
Conversation
pipeline([r, t, w], common.mustCall((err) => { | ||
assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED'); | ||
assert.strictEqual(err.message, | ||
'Cannot call write after a stream was destroyed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the error message more helpful? E.g.: Cannot call write after a 2 stream in pipeline() was destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, it doesn't make sense since ERR_STREAM_DESTROYED
will cause 2 stream to be destroyed because destination stream is passed in destroyed state -- opposite logic here. Also I am not sure if pipeline
really need to be mentioned in error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First destroyed stream in passed arguments should cause all previous streams in pipe chain to be destroyed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only previous streams? All streams should be destroyed like what will happen when some stream is destroyed during pipeline processing.
d6ed804
to
bd4d601
Compare
@nodejs/streams |
I'm sorry this slipped through my notification stream. @ronag wdyt? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, seems good.
Can you please rebase on top of master? Apparently something went wrong with the github merge I did. |
} | ||
|
||
if (isStream(ret) && ret.destroyed) { | ||
finish(new ERR_STREAM_DESTROYED(reading ? 'pipe' : 'write')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not ERR_STREAM_PREMATURE_CLOSE
so it would be consistent with what will happen when the stream is destroyed during pipeline
?
} | ||
|
||
if (isStream(ret) && ret.destroyed) { | ||
finish(new ERR_STREAM_DESTROYED(reading ? 'pipe' : 'write')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a throw
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also would be good if used the isDestroyed
stream utility function.
@kalenikalexander You still interested in finishing this one? Sorry it slipped my notifications. |
Fixes: #36674
Refs: #29227 (comment)
make -j4
test (UNIX), orvcbuild
test (Windows) passes