-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Conversation
Review requested:
|
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Landed in 177d63f |
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>
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>
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