Skip to content

fix(ui): repair shared vitest lane cross-file leaks - #123453

Merged
steipete merged 1 commit into
mainfrom
steipete/cranky-bohr-ea87a3
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cranky-bohr-ea87a3

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

ui/src/app serial runs (OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs ui/src/app) flaked ~2/3 of runs: app-host.test.ts "retries a pending locale once when the Gateway becomes connected" failed with 0 spy calls, route-transition.test.ts failed all 6 tests with "Cannot set property updateComplete ... which has only a getter", and native-link-routing.test.ts produced unhandled NotSupportedError rejections. All passed in isolation and in CI's parallel sharding.

Why This Change Was Made

The non-isolated |ui| lane (isolate: false + OpenClawNonIsolatedRunner) resets the module graph after every test file, but the jsdom document and customElements registry persist for the whole worker. Fresh module singletons (i18n, shell classes) coexist with registry entries from earlier files' dead graphs. Repairs are at the producers per the shared-state rules: the hovercard registration module's define race is guarded inside its single-flight loader (the one production change, +5/-1 LOC); the locale test constructs ShellGatewayOwner directly so spy and callee share one module graph; route-transition defines updateComplete as an own data property (byte-identical to the hunk in open PR #123347, so both merge cleanly). No file needed to join the ui-isolated quarantine list.

User Impact

None at runtime (the guard also removes a real double-define race if two bundles ever load the bootstrap module in one document). Developers get deterministic serial ui/src/app runs.

Evidence

Pre-fix, the new regression test failed exactly as designed:

  • "defines the hovercard once across duplicate bootstrap module instances": expected define calls to have a length of 1 but got 2, plus unhandled NotSupportedError "This name has already been registered in the registry."
  • Locale flake pre-fix: AssertionError: expected "retryPendingLocale" to be called once, but got 0 times (app-host.test.ts:342).
    Post-fix: three consecutive serial whole-directory runs green (60 files passed | 1 skipped; 767 tests passed | 1 skipped; zero Errors lines), plus an independent fourth green run; focused runs of the four touched suites green. Codex autoreview (gpt-5.6-sol, high): clean, "patch is correct (0.99)".

The non-isolated |ui| lane resets the module graph per test file while the
jsdom document and customElements registry persist for the whole worker.
Three producers leaked across that lifetime mismatch:

- github-link-hovercard-registration.ts: each file's module instance adds
  document-level bootstrap listeners; on the first real focusin every stale
  instance raced customElements.define -> unhandled NotSupportedError.
  Guard the define inside the single-flight loader.
- app-host.test.ts locale retry asserted through createElement, which serves
  a sibling graph's shell class bound to a different i18n singleton; construct
  ShellGatewayOwner directly so spy and callee share one graph.
- route-transition.test.ts assigned updateComplete over the real Lit outlet's
  getter-only accessor when a sibling had registered it; define an own data
  property instead (byte-identical to the hunk in PR #123347).

Adds a boundary regression test reproducing the duplicate-module-instance
order; it failed pre-fix with 2 registry defines and the NotSupportedError.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 14, 2026 03:43
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 14, 2026
@steipete
steipete merged commit 92eed63 into main Aug 14, 2026
285 of 296 checks passed
@steipete
steipete deleted the steipete/cranky-bohr-ea87a3 branch August 14, 2026 04:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
The non-isolated |ui| lane resets the module graph per test file while the
jsdom document and customElements registry persist for the whole worker.
Three producers leaked across that lifetime mismatch:

- github-link-hovercard-registration.ts: each file's module instance adds
  document-level bootstrap listeners; on the first real focusin every stale
  instance raced customElements.define -> unhandled NotSupportedError.
  Guard the define inside the single-flight loader.
- app-host.test.ts locale retry asserted through createElement, which serves
  a sibling graph's shell class bound to a different i18n singleton; construct
  ShellGatewayOwner directly so spy and callee share one graph.
- route-transition.test.ts assigned updateComplete over the real Lit outlet's
  getter-only accessor when a sibling had registered it; define an own data
  property instead (byte-identical to the hunk in PR openclaw#123347).

Adds a boundary regression test reproducing the duplicate-module-instance
order; it failed pre-fix with 2 registry defines and the NotSupportedError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant