Skip to content

resultStore run bookkeeping leaks between tests #867

Closed

Description

@EVWorth

Severity: P3 (test reliability).

Since the per-tab results work (#842, PR #866), src/stores/resultStore.ts keeps its run bookkeeping at module level, outside the Zustand state: generations, active executions, orphaned runs and untabbed runs. useResultStore.setState(...) in a test's beforeEach resets the state but not that bookkeeping. A test that fails or times out mid-run therefore leaves its query "in flight", and later tests in the same file fail for reasons unrelated to them. The most exposed is "still counts a closed tab's statement as running until it settles", which checks that nothing is running anywhere.

How to see it

  1. Make any test in resultStore.test.ts fail while one of its deferred() queries is still unresolved.
  2. Run the file. Unrelated tests after it fail, for example anyTabExecuting reads true.

Fix

Export a test-only resetRunBookkeeping(), or a __resetForTests, that clears the module-level maps and counters, and call it from beforeEach in resultStore.test.ts and in the other tests that drive the real store. Alternatively, move the bookkeeping into a closure the store factory creates, so create() gives a fresh copy.

Found while fixing review findings on #866.

Activity

  1. added a commit that references this issue on Oct 29, 2026
    8aabb76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions