From 36322b35ceba102ad5d58bf63220ca10b0e34e84 Mon Sep 17 00:00:00 2001 From: Christian Aurich Zanettini Martins Date: Sun, 8 Nov 2026 22:14:24 -0300 Subject: [PATCH] test: deflake test-fastutf8stream-periodicflush The manual flush case called destroy() right after flush(). destroy() closes the fd without waiting for the write that flush() started, so under load the close can win and the write fails with EBADF. The file was also read on a 500 ms timer instead of after the flush. Destroy the stream and read the file from the flush callback. Signed-off-by: Christian Aurich Zanettini Martins --- test/parallel/test-fastutf8stream-periodicflush.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-fastutf8stream-periodicflush.js b/test/parallel/test-fastutf8stream-periodicflush.js index ed9f8aef883b..e2867369378d 100644 --- a/test/parallel/test-fastutf8stream-periodicflush.js +++ b/test/parallel/test-fastutf8stream-periodicflush.js @@ -65,15 +65,12 @@ function runTests(sync) { assert.ok(stream.write('hello world\n')); // Manually flush to test that data can be written - stream.flush(common.mustSucceed()); - - setTimeout(common.mustCall(() => { + stream.flush(common.mustSucceed(() => { + stream.destroy(); readFile(dest, 'utf8', common.mustSucceed((data) => { assert.strictEqual(data, 'hello world\n'); })); - }), 500); - - stream.destroy(); + })); } {