Skip to content

Commit da136db

Browse files
committed
test: avoid truncating watched worker deps
1 parent 13e90d0 commit da136db

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

test/sequential/test-watch-mode-worker.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ if (common.isIBMi)
1414
common.skip('IBMi does not support `fs.watch()`');
1515

1616
function restart(file, content = readFileSync(file)) {
17-
writeFileSync(file, content);
18-
const timer = setInterval(() => writeFileSync(file, content), common.platformTimeout(250));
17+
const rewrite = () => {
18+
// Avoid truncating files while restarted workers may be reading them.
19+
writeFileSync(file, content, { flag: 'r+' });
20+
};
21+
22+
rewrite();
23+
const timer = setInterval(rewrite, common.platformTimeout(250));
1924
return () => clearInterval(timer);
2025
}
2126

0 commit comments

Comments
 (0)