From d0bba5aeaa4885963794ac4a878405b8c985ecc9 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 7 Nov 2025 02:44:22 +0100 Subject: [PATCH] test: apply a delay to watch-mode-kill-sginal tests The test is still flaking on macOS. This might be caused by fs event coalescing. Apply a delay to reduce the chance of it. Also, add a bit more logs to show more information. --- test/fixtures/kill-signal-for-watch.js | 5 ++++- test/parallel/test-watch-mode-kill-signal-default.mjs | 7 ++++++- test/parallel/test-watch-mode-kill-signal-override.mjs | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/fixtures/kill-signal-for-watch.js b/test/fixtures/kill-signal-for-watch.js index 2beeba099b45ff..fe1e91fb5c3971 100644 --- a/test/fixtures/kill-signal-for-watch.js +++ b/test/fixtures/kill-signal-for-watch.js @@ -7,4 +7,7 @@ process.on('SIGINT', () => { process.exit(); }); process.send(`script ready ${process.pid}`); -setTimeout(() => {}, 100_000); +const timeout = 100_000; +setTimeout(() => { + process._rawDebug(`[CHILD] Timeout ${timeout} fired`); +}, timeout); diff --git a/test/parallel/test-watch-mode-kill-signal-default.mjs b/test/parallel/test-watch-mode-kill-signal-default.mjs index 4d6e7bcef8c795..53aec43d22e050 100644 --- a/test/parallel/test-watch-mode-kill-signal-default.mjs +++ b/test/parallel/test-watch-mode-kill-signal-default.mjs @@ -51,7 +51,12 @@ child.on('message', (msg) => { const match = msg.match(/script ready (\d+)/); if (match) { firstGrandchildPid = match[1]; // This is the first grandchild - writeFileSync(indexPath, indexContents); + const writeDelay = 1000; // Delay to reduce the chance of fs events coalescing + console.log(`[PARENT] writing to restart ${firstGrandchildPid} after ${writeDelay}ms`); + setTimeout(() => { + console.log(`[PARENT] writing to ${indexPath} to restart ${firstGrandchildPid}`); + writeFileSync(indexPath, indexContents); + }, writeDelay); } } }); diff --git a/test/parallel/test-watch-mode-kill-signal-override.mjs b/test/parallel/test-watch-mode-kill-signal-override.mjs index 37f6b7e20ffc7c..dc3af3f76e848d 100644 --- a/test/parallel/test-watch-mode-kill-signal-override.mjs +++ b/test/parallel/test-watch-mode-kill-signal-override.mjs @@ -52,7 +52,12 @@ child.on('message', (msg) => { const match = msg.match(/script ready (\d+)/); if (match) { firstGrandchildPid = match[1]; // This is the first grandchild - writeFileSync(indexPath, indexContents); + const writeDelay = 1000; // Delay to reduce the chance of fs events coalescing + console.log(`[PARENT] writing to restart ${firstGrandchildPid} after ${writeDelay}ms`); + setTimeout(() => { + console.log(`[PARENT] writing to ${indexPath} to restart ${firstGrandchildPid}`); + writeFileSync(indexPath, indexContents); + }, writeDelay); } } });