Description
Test Web on PR #5260 (run 34194497917) reported 825 files passed and then exited 1 with:
Vitest caught 1 unhandled error during the test run.
ReferenceError: window is not defined
❯ Timeout._onTimeout src/components/scripts/ScriptExecutionModal.tsx:306:11
This error originated in "src/components/scripts/ScriptExecutionModal.test.tsx"
A setTimeout in ScriptExecutionModal outlives the test that scheduled it and touches window after the jsdom environment is torn down. It is load-dependent (a rerun of the same commit passed), so it presents as a flake.
Proposed Fix
Clear the timer on unmount (useEffect cleanup / clearTimeout in the modal's close path) and, in the test, use fake timers or await the pending timeout before the test ends. Add a regression assertion that no timers remain after unmount.
Affected Files
apps/web/src/components/scripts/ScriptExecutionModal.tsx (~L306)
apps/web/src/components/scripts/ScriptExecutionModal.test.tsx
Reported By
Orchestrator, 2026-09-08, while landing #5260.
Description
Test Web on PR #5260 (run 34194497917) reported 825 files passed and then exited 1 with:
A
setTimeoutinScriptExecutionModaloutlives the test that scheduled it and toucheswindowafter the jsdom environment is torn down. It is load-dependent (a rerun of the same commit passed), so it presents as a flake.Proposed Fix
Clear the timer on unmount (
useEffectcleanup /clearTimeoutin the modal's close path) and, in the test, use fake timers orawaitthe pending timeout before the test ends. Add a regression assertion that no timers remain after unmount.Affected Files
apps/web/src/components/scripts/ScriptExecutionModal.tsx(~L306)apps/web/src/components/scripts/ScriptExecutionModal.test.tsxReported By
Orchestrator, 2026-09-08, while landing #5260.