Skip to content

[Test Web] ScriptExecutionModal leaks a timer that fires after jsdom teardown — 'window is not defined' fails the job with 825/825 passing #5270

Description

@ToddHebebrand

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions