Skip to content

Commit

Permalink
stream: callback should be called when pendingcb is 0
Browse files Browse the repository at this point in the history
Fixes: #46170
  • Loading branch information
jakecastelli committed Jun 13, 2024
1 parent 5a19a9b commit 02c7662
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ function eos(stream, options, callback) {
(!willEmitClose || isReadable(stream)) &&
(writableFinished || isWritable(stream) === false)
) {
process.nextTick(onclosed);
if (wState && wState.pendingcb === 0) {
process.nextTick(onclosed);
}
} else if (
!writable &&
(!willEmitClose || isWritable(stream)) &&
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 682 in test/parallel/test-stream-finished.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon
}));
}

0 comments on commit 02c7662

Please sign in to comment.