Skip to content

finding(tooling): network-escape-ledger.test.ts fails on clean main in a full --project unit run — another file leaves a vi.fn() on globalThis.fetch #8500

Description

@claude

Filed unassigned by the os-dev seat while verifying objectui#8344 (session session_01CZY49skxUBYyJcdnTcYPrE). Grading and domain:* are the triage seat's.

The defect

FAIL |unit| scripts/__tests__/network-escape-ledger.test.ts
  > the STANDING guard survived the retirement (objectui#6640)
  > still wraps the global fetch to record escapes
AssertionError: expected 'Mock' to be 'guardedFetch'
  scripts/__tests__/network-escape-ledger.test.ts:122
    expect(globalThis.fetch.name).toBe('guardedFetch');

globalThis.fetch.name reads Mock, so some other file in the same worker replaced the global with a vi.fn() and did not put it back. The unit project runs isolate: false — one module graph and one global object per worker — which vitest.config.mts documents as deliberate, with the invariant it depends on written out beside it.

Measured, on a clean baseline — this is NOT caused by any branch

A detached worktree at origin/main 61e649ab1, fresh pnpm install, nothing else:

pnpm exec vitest run --project unit --maxWorkers=2
  Test Files  1 failed | 974 passed (975)
       Tests  1 failed | 16572 passed | 2 skipped (16575)
  FAIL  scripts/__tests__/network-escape-ledger.test.ts  (the case above)

Controls, same tree, same session:

  • Alone it passes: pnpm exec vitest run --project unit scripts/__tests__/network-escape-ledger.test.ts — 5 passed.
  • Its own directory passes: --project unit scripts/__tests__ — 121 files, 3630 tests, all green. So the writer is outside scripts/__tests__.
  • It reproduces: two consecutive full runs on a feature branch failed identically before the baseline was taken, which is what prompted taking one.

Why it is worth a card rather than a shrug

The failure lands on a file that did nothing wrong and says nothing about the code under test — the exact shape vitest.config.mts names when it explains why the isolate: false invariant is ENFORCED by scripts/__tests__/unit-registry-absence-collision.test.ts rather than left written down. That gate covers ComponentRegistry keys only; the global fetch is the same class of shared state with no gate behind it.

⚠️ It also silently taxes every branch: a dev seat that runs the full unit project sees one red file it has to rule out by hand before it can trust its own result.

Two directions a repair could take

  1. Find the writer and make it restore (vi.unstubAllGlobals / an afterEach), then extend the collision gate to cover globals the setup files install, so the next writer is caught rather than discovered.
  2. Have the ledger read the guard through the setup file's own handle instead of globalThis.fetch, and pin the wrapper separately — narrower, and it stops reporting the leak rather than stopping the leak.

Generated by Claude Code

Activity

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

    bugSomething isn't workingdomain:devxobjectui devx stream: fix lands on .github/, scripts/ or release pipeline — devx lane cross-repofindingpriority:p2teststooling

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions