Skip to content
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

stream: allow readable to end early without error #40881

Closed
wants to merge 5 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Nov 19, 2021

No description provided.

@ronag ronag requested a review from mcollina November 19, 2021 13:03
@ronag
Copy link
Member Author

ronag commented Nov 19, 2021

@nodejs/streams

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Nov 19, 2021
@ronag ronag 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
Member Author

ronag commented Nov 19, 2021

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

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

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 19, 2021
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 19, 2021
@nodejs-github-bot
Copy link
Collaborator

} else {
ret = makeAsyncIterable(ret);

} else if (isIterable(ret)) {
finishCount++;
pump(ret, stream, finish);
Copy link
Member Author

@ronag ronag Nov 22, 2021

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
Member Author

ronag commented Nov 25, 2021

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

@nodejs-github-bot
Copy link
Collaborator

return ret;
}, common.mustCall((err, val) => {
assert.strictEqual(err, undefined);
assert.strictEqual(val, 'helloworld');
Copy link
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
Member Author

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

Copy link
Member

@lpinca lpinca Dec 5, 2021

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
Member Author

Choose a reason for hiding this comment

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

Fixed, PTAL, f0ec29b

@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Dec 5, 2021
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Dec 5, 2021
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@lpinca lpinca left a comment

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
Copy link
Collaborator

nodejs-github-bot commented Dec 6, 2021

@ronag
Copy link
Member Author

ronag commented Dec 6, 2021

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

Linkgoron pushed a commit to Linkgoron/node that referenced this pull request Jan 31, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. review wanted PRs that need reviews. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants