Skip to content

Commit

Permalink
fixup! expand the test
Browse files Browse the repository at this point in the history
Make sure the callback in `write` is called before the callback in
finished
  • Loading branch information
jakecastelli committed Jun 13, 2024
1 parent 84580ed commit b052a0c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,21 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
}

{
let isCalld = false;
const stream = new Duplex({
write(chunk, enc, cb) {
setImmediate(cb);
setImmediate(() => {
isCalld = true;
cb();
});
}
});

stream.end('foo');

finished(stream, { readable: false }, common.mustCall((err) => {
assert(!err);
assert.strictEqual(isCalld, true);
assert.strictEqual(stream._writableState.pendingcb, 0);
}));
}

0 comments on commit b052a0c

Please sign in to comment.