From cc3a70598cff7d3dbd34d85adb03cc655c558361 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 9 Oct 2025 07:33:33 +0200 Subject: [PATCH] test: deflake test-fs-promises-watch-iterator Add a delay before writing the files to ensure that the watcher receives the notifications. Fixes: https://github.com/nodejs/node/issues/60051 Refs: https://github.com/nodejs/node/issues/52601 PR-URL: https://github.com/nodejs/node/pull/60060 Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung --- test/parallel/test-fs-promises-watch-iterator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-fs-promises-watch-iterator.js b/test/parallel/test-fs-promises-watch-iterator.js index 1606bdef422..f8b30c33f08 100644 --- a/test/parallel/test-fs-promises-watch-iterator.js +++ b/test/parallel/test-fs-promises-watch-iterator.js @@ -34,10 +34,12 @@ class WatchTestCase { } } async writeFiles() { + // Do the write with a delay to ensure that the OS is ready to notify us. + await setTimeout(common.platformTimeout(100)); + for (const fileName of [...this.files]) { await writeFile(this.filePath(fileName), Date.now() + fileName.repeat(1e4)); } - await setTimeout(common.platformTimeout(100)); } }