mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
stream: callback should be called when pendingcb is 0
Fixes: https://github.com/nodejs/node/issues/46170 PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
2aceed4297
commit
33a15be32f
2 files changed
+9
-2
No files matched your search
@@ -214,7 +214,8 @@ function eos(stream, options, callback) {
|
||||
} else if (
|
||||
!readable &&
|
||||
(!willEmitClose || isReadable(stream)) &&
|
||||
(writableFinished || isWritable(stream) === false)
|
||||
(writableFinished || isWritable(stream) === false) &&
|
||||
(wState == null || wState.pendingcb === 0)
|
||||
) {
|
||||
process.nextTick(onclosed);
|
||||
} else if (
|
||||
|
||||
@@ -669,9 +669,13 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
|
||||
}
|
||||
|
||||
{
|
||||
let isCalled = false;
|
||||
const stream = new Duplex({
|
||||
write(chunk, enc, cb) {
|
||||
setImmediate(cb);
|
||||
setImmediate(() => {
|
||||
isCalled = true;
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -679,5 +683,7 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
|
||||
|
||||
finished(stream, { readable: false }, common.mustCall((err) => {
|
||||
assert(!err);
|
||||
assert.strictEqual(isCalled, true);
|
||||
assert.strictEqual(stream._writableState.pendingcb, 0);
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user