stream: callback should be called when pendingcb is 0#53438
Conversation
|
Review requested:
|
|
|
||
| finished(stream, { readable: false }, common.mustCall((err) => { | ||
| assert(!err); | ||
| assert.strictEqual(stream._writableState.pendingcb, 0); |
There was a problem hiding this comment.
Can you add a test that does not look into _writableState? Why are you doing this change?
There was a problem hiding this comment.
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.
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.
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
pendingcbis 0.Time spent on this issue: 12 hours+, I would appreciate any comment or feedback on this π
Fixes: #46170