Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
joyeecheung committed Nov 7, 2025
commit d0bba5aeaa4885963794ac4a878405b8c985ecc9
5 changes: 4 additions & 1 deletion test/fixtures/kill-signal-for-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
7 changes: 6 additions & 1 deletion test/parallel/test-watch-mode-kill-signal-default.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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

@joyeecheung joyeecheung Nov 7, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% sure that this would eliminate the effect of coalescing for this test - another option is to, er, write a few more times and cross fingers that they get picked by the fsevent-based watcher? But multiple writes could again lead to the tricky loop we wanted to avoid in #60443. So for now I guess we can just try the timeout and hopefully that is good enough..

console.log(`[PARENT] writing to restart ${firstGrandchildPid} after ${writeDelay}ms`);
setTimeout(() => {
console.log(`[PARENT] writing to ${indexPath} to restart ${firstGrandchildPid}`);
writeFileSync(indexPath, indexContents);
}, writeDelay);
}
}
});
Expand Down
7 changes: 6 additions & 1 deletion test/parallel/test-watch-mode-kill-signal-override.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
});
Expand Down
Loading