From 1a627f938a4074a36d1dc24e164991f0bb63045e Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Sun, 17 May 2026 14:27:04 -0700 Subject: [PATCH] test: reduce watch mode restart flakiness Start waiting for each watch restart before writing the file, then wait for a platform-scaled settling period before mutating it again. This gives watch mode time to process filesystem events and dependency reporting from the child process on slower CI machines. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 --- .../test-watch-mode-restart-esm-loading-error.mjs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/sequential/test-watch-mode-restart-esm-loading-error.mjs b/test/sequential/test-watch-mode-restart-esm-loading-error.mjs index 42618adaffd386..95a62423160af9 100644 --- a/test/sequential/test-watch-mode-restart-esm-loading-error.mjs +++ b/test/sequential/test-watch-mode-restart-esm-loading-error.mjs @@ -7,6 +7,7 @@ import { spawn } from 'node:child_process'; import { writeFileSync } from 'node:fs'; import { inspect } from 'node:util'; import { createInterface } from 'node:readline'; +import { setTimeout as sleep } from 'node:timers/promises'; if (common.isIBMi) common.skip('IBMi does not support `fs.watch()`'); @@ -112,19 +113,21 @@ try { // Update file with syntax error const syntaxErrorContent = `console.log('hello, wor`; + const failedRestart = restart(common.platformTimeout(10_000)); writeFileSync(file, syntaxErrorContent); - + await sleep(common.platformTimeout(1000)); // Wait for the failed restart - const { stderr: stderr2, stdout: stdout2 } = await restart(); + const { stderr: stderr2, stdout: stdout2 } = await failedRestart; assert.match(stderr2, /SyntaxError: Invalid or unexpected token/); assert.deepStrictEqual(stdout2, [ `Restarting ${inspect(file)}`, `Failed running ${inspect(file)}. Waiting for file changes before restarting...`, ]); + const successfulRestart = restart(common.platformTimeout(10_000)); writeFileSync(file, `console.log('hello again, world');`); - - const { stderr: stderr3, stdout: stdout3 } = await restart(); + await sleep(common.platformTimeout(1000)); + const { stderr: stderr3, stdout: stdout3 } = await successfulRestart; // Verify it recovered and ran successfully assert.strictEqual(stderr3, '');