Repository navigation
fix(ui): repair shared vitest lane cross-file leaks - #123453
Merged
Merged
Conversation
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.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
August 14, 2026 03:43
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 constructsShellGatewayOwnerdirectly so spy and callee share one module graph; route-transition definesupdateCompleteas an own data property (byte-identical to the hunk in open PR #123347, so both merge cleanly). No file needed to join theui-isolatedquarantine 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/appruns.Evidence
Pre-fix, the new regression test failed exactly as designed:
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)".