stream: allow readable to end early without error#40881
stream: allow readable to end early without error#40881ronag wants to merge 5 commits intonodejs:masterfrom
Conversation
|
@nodejs/streams |
|
@benjamingr I think this PR will be necessary for e.g. take(n). |
lib/internal/streams/pipeline.js
Outdated
|
|
||
| } else if (isIterable(ret)) { | ||
| finishCount++; | ||
| pump(ret, stream, finish); |
There was a problem hiding this comment.
pump has its own cleanup logic through async iterator.
|
@nodejs/streams I noticed some other issues while working on this. Please see updated tests. |
| return ret; | ||
| }, common.mustCall((err, val) => { | ||
| assert.strictEqual(err, undefined); | ||
| assert.strictEqual(val, 'helloworld'); |
There was a problem hiding this comment.
This test seems to be broken. val is undefined, I'm not sure why the thrown exception does not make the process exit. I did not investigate.
There was a problem hiding this comment.
Yea.. that's weird. Fixed the test.
There was a problem hiding this comment.
Updated test looks good, but why the process did not exit?
There was a problem hiding this comment.
I can reproduce the same issue with current Node.js version (v17.2.0) so it is not related to this PR but it is something to investigate and fix.
There was a problem hiding this comment.
It seems that the error thrown in the callback is caught and swallowed here
node/lib/internal/streams/pipeline.js
Lines 163 to 164 in 147d23b
|
Landed in 1fa507f |
PR-URL: #40881 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #40881 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: #40881 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
|
@ronag do you mind making a backport PR for this for v16.x-staging? It did not land cleanly when pulling into the 16.x release. |
PR-URL: nodejs#40881 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
No description provided.