Repository navigation
stream: improve Readable.from error handling - #37158
benjamingr wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
This is tricky and I want feedback on the semantics, basically:
- If we had an error (
.destroy(err)) we call.throw- this aligns the behaviour of.fromwith other methods and means stuff likeaddAbortSignalautomagically "works". - If after calling
throwthe iterator did not finish - we also call.return
There was a problem hiding this comment.
This check is no longer necessary without needToClose since _destroy is called and if the stream is destroyed the iterator is closed.
There was a problem hiding this comment.
Wouldn't error be null?
node/lib/internal/streams/destroy.js
Line 67 in 683754c
3f712a5 to
0bce498
Compare
|
I've rebased and force pushed to solve to git conflicts introduced by my PR. |
commented
Feb 1, 2021
|
@aduh95 very kind of you, thanks 🙇♂️ |
commented
Feb 1, 2021
commented
Feb 2, 2021
commented
Feb 2, 2021
|
@mcollina I might be a bit overcautious* - but I prefer to err on the side of caution. What steps can I take to ensure there is less breakage here? Thoughts:
Anything else? (since the old behaviour was just an overlooked bug/edge-case and probably not relied on) |
commented
Feb 2, 2021
|
Putting "blocked" so this doesn't land by accident in the meantime. |
commented
Feb 2, 2021
|
I went through most CITGM failures and there don't seem to be new/related ones |
commented
Feb 2, 2021
commented
Feb 2, 2021
commented
Feb 3, 2021
commented
Feb 3, 2021
|
I do not think we have any modules using this in CITGM. It's not touching any old/critical APIs, so it should be good to land. |
commented
Feb 3, 2021
|
Thanks matteo. Landed in 03380bc |
This pull request aligns the behaviour of
Readable.fromwith other stream behaviours namely:.throwand not via.onand reach catch blocks. This means things likeaddAbortSignalwork withReadable.fromnow.nextwas not called - this is because the previous implementation had a timing bug where ifnextwas called and the stream was destroyed in the same tick - finally blocks would not run.cc @ronag @mcollina @nodejs/streams