Skip to content

stream: allow readable to end early without error - #40881

Closed
ronag wants to merge 5 commits into
nodejs:masterfrom
nxtedition:readable-take
Closed

stream: allow readable to end early without error#40881
ronag wants to merge 5 commits into
nodejs:masterfrom
nxtedition:readable-take

Conversation

@ronag

Copy link
Copy Markdown
Member

No description provided.

@ronag
ronag requested a review from mcollinaNovember 19, 2021 13:03
@ronag

Copy link
Copy Markdown
MemberAuthor

@nodejs/streams

@nodejs-github-botnodejs-github-bot added the needs-ci PRs that need a full CI run. label Nov 19, 2021
@ronagronag added request-ci Add this label to start a Jenkins CI on a PR. stream Issues and PRs related to the stream subsystem. and removed needs-ci PRs that need a full CI run. labels Nov 19, 2021
@ronag

Copy link
Copy Markdown
MemberAuthor

@benjamingr I think this PR will be necessary for e.g. take(n).

@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 19, 2021
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ronagronag added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 19, 2021
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 19, 2021
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment threadlib/internal/streams/pipeline.js Outdated

@ronagronagNov 22, 2021

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pump has its own cleanup logic through async iterator.

@ronag
ronag marked this pull request as draft November 23, 2021 11:37
@ronag
ronag marked this pull request as ready for review November 25, 2021 20:02
@ronag

Copy link
Copy Markdown
MemberAuthor

@nodejs/streams I noticed some other issues while working on this. Please see updated tests.

Comment threadlib/internal/streams/pipeline.js Outdated
Comment threadlib/internal/streams/pipeline.js Outdated
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

return ret;
}, common.mustCall((err, val) => {
assert.strictEqual(err, undefined);
assert.strictEqual(val, 'helloworld');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea.. that's weird. Fixed the test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated test looks good, but why the process did not exit?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lpincalpincaDec 5, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the error thrown in the callback is caught and swallowed here

}catch(err){
finish(error!==err ? aggregateTwoErrors(error,err) : err);
.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, PTAL, f0ec29b

@ronagronag added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 5, 2021
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 5, 2021
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@lpincalpinca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a test for cf85105?

@nodejs-github-bot

nodejs-github-bot commented Dec 6, 2021

Copy link
Copy Markdown
Collaborator

@ronag

ronag commented Dec 6, 2021

Copy link
Copy Markdown
MemberAuthor

Landed in 1fa507f

ronag added a commit that referenced this pull request Dec 6, 2021
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>
@ronagronag closed this Dec 6, 2021
danielleadams pushed a commit that referenced this pull request Dec 14, 2021
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>
@danielleadams

Copy link
Copy Markdown
Contributor

@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.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.review wantedPRs that need reviews.streamIssues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@ronag@nodejs-github-bot@danielleadams@mcollina@jasnell@wa-Nadoo@lpinca@targos