Skip to content

Commit 9297d29

Browse files
jakecastellitargos
authored andcommitted
stream: make checking pendingcb on WritableStream backward compatible
PR-URL: #54142Fixes: #54131 Refs: #54131 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
1 parent 4d8b53e commit 9297d29

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎lib/internal/streams/end-of-stream.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function eos(stream, options, callback) {
214214
!readable&&
215215
(!willEmitClose||isReadable(stream))&&
216216
(writableFinished||isWritable(stream)===false)&&
217-
(wState==null||wState.pendingcb===0)
217+
(wState==null||wState.pendingcb===undefined||wState.pendingcb===0)
218218
){
219219
process.nextTick(onclosed);
220220
}elseif(

‎test/parallel/test-stream-finished.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,3 +687,16 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
687687
assert.strictEqual(stream._writableState.pendingcb,0);
688688
}));
689689
}
690+
691+
{
692+
conststream=newDuplex({
693+
write(chunk,enc,cb){}
694+
});
695+
696+
stream.end('foo');
697+
698+
// Simulate an old stream implementation that doesn't have pendingcb
699+
deletestream._writableState.pendingcb;
700+
701+
finished(stream,{readable: false},common.mustCall());
702+
}

0 commit comments

Comments
 (0)