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: callback should be called when pendingcb is 0 #53438

Merged
merged 5 commits into from
Jun 15, 2024

Conversation

jakecastelli
Copy link
Member

@jakecastelli jakecastelli commented Jun 13, 2024

The callback should be called when the pendingcb is 0.

Time spent on this issue: 12 hours+, I would appreciate any comment or feedback on this 🙏

Fixes: #46170

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem. labels Jun 13, 2024
@jakecastelli jakecastelli changed the title stream: callback should be called when there pendingcb is 0 stream: callback should be called when pendingcb is 0 Jun 13, 2024
@jakecastelli jakecastelli marked this pull request as ready for review June 13, 2024 07:28
@@ -679,5 +679,6 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));

finished(stream, { readable: false }, common.mustCall((err) => {
assert(!err);
assert.strictEqual(stream._writableState.pendingcb, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test that does not look into _writableState? Why are you doing this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, I will add a new test to address it, thanks!

Why are you doing this change?

Do you mean the change to the test? If so, it is because when the callback function is called in stream.finished it won't wait for the callback in the writable._write (if any async action is performed) and one of the indication is stream._writableState.pendingcb is not 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have expanded the test to make sure the cb in _write is called before the cb in finished is called. PTAL @mcollina 🙏

Make sure the callback in `write` is called before the callback in
finished
Co-authored-by: Robert Nagy <ronagy@icloud.com>
@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 13, 2024
@nodejs-github-bot

This comment was marked as outdated.

@atlowChemi atlowChemi added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jun 13, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 14, 2024
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Jun 14, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 15, 2024
@nodejs-github-bot nodejs-github-bot merged commit 177d63f into nodejs:main Jun 15, 2024
54 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 177d63f

targos pushed a commit that referenced this pull request Jun 20, 2024
Fixes: #46170
PR-URL: #53438
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
eliphazbouye pushed a commit to eliphazbouye/node that referenced this pull request Jun 20, 2024
Fixes: nodejs#46170
PR-URL: nodejs#53438
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
bmeck pushed a commit to bmeck/node that referenced this pull request Jun 22, 2024
Fixes: nodejs#46170
PR-URL: nodejs#53438
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Jul 19, 2024
Fixes: #46170
PR-URL: #53438
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Jul 19, 2024
Fixes: #46170
PR-URL: #53438
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@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. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stream.finished calls callback when writable stream still has pending callbacks
7 participants