Skip to content

Commit f0d81c9

Browse files
joyeecheungaduh95
authored andcommitted
test: apply a delay to watch-mode-kill-signal 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. PR-URL: #60610 Refs: https://github.com/nodejs/reliability/blob/main/reports/2025-11-07.md Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 3e11658 commit f0d81c9

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

test/fixtures/kill-signal-for-watch.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ process.on('SIGINT', () => {
77
process.exit();
88
});
99
process.send(`script ready ${process.pid}`);
10-
setTimeout(() => {}, 100_000);
10+
const timeout = 100_000;
11+
setTimeout(() => {
12+
process._rawDebug(`[CHILD] Timeout ${timeout} fired`);
13+
}, timeout);

test/parallel/test-watch-mode-kill-signal-default.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ child.on('message', (msg) => {
5151
const match = msg.match(/script ready (\d+)/);
5252
if (match) {
5353
firstGrandchildPid = match[1]; // This is the first grandchild
54-
writeFileSync(indexPath, indexContents);
54+
const writeDelay = 1000; // Delay to reduce the chance of fs events coalescing
55+
console.log(`[PARENT] writing to restart ${firstGrandchildPid} after ${writeDelay}ms`);
56+
setTimeout(() => {
57+
console.log(`[PARENT] writing to ${indexPath} to restart ${firstGrandchildPid}`);
58+
writeFileSync(indexPath, indexContents);
59+
}, writeDelay);
5560
}
5661
}
5762
});

test/parallel/test-watch-mode-kill-signal-override.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ child.on('message', (msg) => {
5252
const match = msg.match(/script ready (\d+)/);
5353
if (match) {
5454
firstGrandchildPid = match[1]; // This is the first grandchild
55-
writeFileSync(indexPath, indexContents);
55+
const writeDelay = 1000; // Delay to reduce the chance of fs events coalescing
56+
console.log(`[PARENT] writing to restart ${firstGrandchildPid} after ${writeDelay}ms`);
57+
setTimeout(() => {
58+
console.log(`[PARENT] writing to ${indexPath} to restart ${firstGrandchildPid}`);
59+
writeFileSync(indexPath, indexContents);
60+
}, writeDelay);
5661
}
5762
}
5863
});

0 commit comments

Comments
 (0)