From cfcd3e7f3762c47a07a3f260e596cf237a8035f4 Mon Sep 17 00:00:00 2001 From: inoway46 Date: Sat, 2 May 2026 23:41:52 +0900 Subject: [PATCH] test: avoid truncating watched worker deps Signed-off-by: inoway46 --- test/sequential/test-watch-mode-worker.mjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-watch-mode-worker.mjs b/test/sequential/test-watch-mode-worker.mjs index b7bc1a94a87ba4..45fd70ee8d2ad1 100644 --- a/test/sequential/test-watch-mode-worker.mjs +++ b/test/sequential/test-watch-mode-worker.mjs @@ -14,8 +14,13 @@ if (common.isIBMi) common.skip('IBMi does not support `fs.watch()`'); function restart(file, content = readFileSync(file)) { - writeFileSync(file, content); - const timer = setInterval(() => writeFileSync(file, content), common.platformTimeout(250)); + const rewrite = () => { + // Avoid truncating files while restarted workers may be reading them. + writeFileSync(file, content, { flag: 'r+' }); + }; + + rewrite(); + const timer = setInterval(rewrite, common.platformTimeout(250)); return () => clearInterval(timer); }