mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
stream: make checking pendingcb on WritableStream backward compatible
PR-URL: https://github.com/nodejs/node/pull/54142 Fixes: https://github.com/nodejs/node/issues/54131 Refs: https://github.com/nodejs/node/issues/54131 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
This commit is contained in:
parent
a8166880f1
commit
fafc845089
@ -214,7 +214,7 @@ function eos(stream, options, callback) {
|
||||
!readable &&
|
||||
(!willEmitClose || isReadable(stream)) &&
|
||||
(writableFinished || isWritable(stream) === false) &&
|
||||
(wState == null || wState.pendingcb === 0)
|
||||
(wState == null || wState.pendingcb === undefined || wState.pendingcb === 0)
|
||||
) {
|
||||
process.nextTick(onclosed);
|
||||
} else if (
|
||||
|
@ -687,3 +687,16 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
|
||||
assert.strictEqual(stream._writableState.pendingcb, 0);
|
||||
}));
|
||||
}
|
||||
|
||||
{
|
||||
const stream = new Duplex({
|
||||
write(chunk, enc, cb) {}
|
||||
});
|
||||
|
||||
stream.end('foo');
|
||||
|
||||
// Simulate an old stream implementation that doesn't have pendingcb
|
||||
delete stream._writableState.pendingcb;
|
||||
|
||||
finished(stream, { readable: false }, common.mustCall());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user