From b052a0cede9c058e85805c0891a45161b489319b Mon Sep 17 00:00:00 2001 From: jakecastelli <959672929@qq.com> Date: Thu, 13 Jun 2024 19:54:12 +0930 Subject: [PATCH] fixup! expand the test Make sure the callback in `write` is called before the callback in finished --- test/parallel/test-stream-finished.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-stream-finished.js b/test/parallel/test-stream-finished.js index d1b30079b7dd2c..010f953f099f8e 100644 --- a/test/parallel/test-stream-finished.js +++ b/test/parallel/test-stream-finished.js @@ -669,9 +669,13 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); } { + let isCalld = false; const stream = new Duplex({ write(chunk, enc, cb) { - setImmediate(cb); + setImmediate(() => { + isCalld = true; + cb(); + }); } }); @@ -679,6 +683,7 @@ testClosed((opts) => new Writable({ write() {}, ...opts })); finished(stream, { readable: false }, common.mustCall((err) => { assert(!err); + assert.strictEqual(isCalld, true); assert.strictEqual(stream._writableState.pendingcb, 0); })); }