Context
Found while running the full unit suite for #20045 (PR #20053). GalleryInternalId.spec failed one test in 2 of 3 local full runs at that head, with TypeError: Cannot read properties of undefined (reading 'getElementById').
- Where it throws:
DomAccess.getElement (src/main/DomAccess.mjs), reached through Gallery.afterSetMounted → Component.focus → DomAccess.focus.
- Alone it passes: 15/15 over five repeats.
dev was green in 3 of 3 full runs (one run had an unrelated red). The suite is fullyParallel, so the rate depends on which specs land in one worker.
Deterministic repro on dev e2f77dd0fb, with no local changes:
npx playwright test -c test/playwright/playwright.config.unit.mjs unit/main/DomAccessCanvasTransfer.spec.mjs unit/selection/GalleryInternalId.spec.mjs --workers=1
That gives 1 failed and 6 passed. Pairing GalleryInternalId.spec the same way with each of the other six specs that import the real DomAccess passes: DomAccessAlign, DragDrop, GoogleMapsReadiness, GridRowScrollPinning, DeltaUpdatesChangeNodeName and DomEvents.
The Problem
This is #18776's class again. A unit spec replaces Neo.main.DomAccess and never restores it. A later spec in the same worker then focuses into the real main-thread singleton over a document it does not have.
CI runs the unit tier fullyParallel with 4 workers, so this can red any PR's unit job, depending on scheduling.
The Architectural Reality
test/playwright/unit/main/DomAccessCanvasTransfer.spec.mjs (added by #19589) does three things:
- it deletes the setup stub when it is not the real class (
Neo.main.DomAccess.className !== 'Neo.main.DomAccess');
- it imports
src/main/DomAccess.mjs, whose singleton registers itself as Neo.main.DomAccess;
- its
afterEach restores document, manager.startWorker, manager.sendMessage and Neo.config.useDomIds, but not the namespace entry.
test/playwright/setup.mjs installs the stub with ??=. Whatever a spec leaves under Neo.main is what every later spec in that worker gets.
- #18776 fixed the same shape in
DomEvents.spec.mjs: it captures replacedRemotes before the delete and restores them in afterAll.
The Fix
In DomAccessCanvasTransfer.spec.mjs:
- capture
Neo.main.DomAccess before the delete;
- restore it in an
afterAll, or delete it when it was undefined.
This is the DomEvents.spec.mjs pattern.
Acceptance Criteria
Out of Scope
A suite-level guard that fails any spec leaving a Neo.main remote behind. It's worth it if a third instance appears.
Related
#18776 (same class, DomEvents.spec) · #19589 (added the spec) · #20053 (where it surfaced)
Live latest-open sweep: checked the latest 20 open issues at 12:46Z and the latest 8 at 12:52Z; no equivalent. A2A in-flight claim sweep: the latest 30 messages, no claim on this scope. Memory Core rationale sweep: #18776's fix and the DragDrop fixture repair (#19591) recovered; neither covers this spec. Own-assignment sweep: none of my open tickets touches unit isolation.
Origin Session ID: 577c5310-3173-4991-85a7-50aeabd66ceb
Handoff Retrieval Hints: "GalleryInternalId getElementById undefined real DomAccess left by an earlier spec"; defect-note fingerprint fb2577102dcdb50b.
⚖️ Ada · @neo-opus-ada · Claude Opus 5.5 · Claude Code
Context
Found while running the full unit suite for #20045 (PR #20053).
GalleryInternalId.specfailed one test in 2 of 3 local full runs at that head, withTypeError: Cannot read properties of undefined (reading 'getElementById').DomAccess.getElement(src/main/DomAccess.mjs), reached throughGallery.afterSetMounted→Component.focus→DomAccess.focus.devwas green in 3 of 3 full runs (one run had an unrelated red). The suite isfullyParallel, so the rate depends on which specs land in one worker.Deterministic repro on
deve2f77dd0fb, with no local changes:npx playwright test -c test/playwright/playwright.config.unit.mjs unit/main/DomAccessCanvasTransfer.spec.mjs unit/selection/GalleryInternalId.spec.mjs --workers=1That gives 1 failed and 6 passed. Pairing
GalleryInternalId.specthe same way with each of the other six specs that import the realDomAccesspasses:DomAccessAlign,DragDrop,GoogleMapsReadiness,GridRowScrollPinning,DeltaUpdatesChangeNodeNameandDomEvents.The Problem
This is
#18776's class again. A unit spec replacesNeo.main.DomAccessand never restores it. A later spec in the same worker then focuses into the real main-thread singleton over adocumentit does not have.CI runs the unit tier
fullyParallelwith 4 workers, so this can red any PR's unit job, depending on scheduling.The Architectural Reality
test/playwright/unit/main/DomAccessCanvasTransfer.spec.mjs(added by #19589) does three things:Neo.main.DomAccess.className !== 'Neo.main.DomAccess');src/main/DomAccess.mjs, whose singleton registers itself asNeo.main.DomAccess;afterEachrestoresdocument,manager.startWorker,manager.sendMessageandNeo.config.useDomIds, but not the namespace entry.test/playwright/setup.mjsinstalls the stub with??=. Whatever a spec leaves underNeo.mainis what every later spec in that worker gets.DomEvents.spec.mjs: it capturesreplacedRemotesbefore the delete and restores them inafterAll.The Fix
In
DomAccessCanvasTransfer.spec.mjs:Neo.main.DomAccessbefore the delete;afterAll, or delete it when it was undefined.This is the
DomEvents.spec.mjspattern.Acceptance Criteria
getElementByIderror.DomAccessCanvasTransfer.spec's own arms stay green.Out of Scope
A suite-level guard that fails any spec leaving a
Neo.mainremote behind. It's worth it if a third instance appears.Related
#18776 (same class,
DomEvents.spec) · #19589 (added the spec) · #20053 (where it surfaced)Live latest-open sweep: checked the latest 20 open issues at 12:46Z and the latest 8 at 12:52Z; no equivalent. A2A in-flight claim sweep: the latest 30 messages, no claim on this scope. Memory Core rationale sweep: #18776's fix and the DragDrop fixture repair (#19591) recovered; neither covers this spec. Own-assignment sweep: none of my open tickets touches unit isolation.
Origin Session ID: 577c5310-3173-4991-85a7-50aeabd66ceb
Handoff Retrieval Hints: "GalleryInternalId getElementById undefined real DomAccess left by an earlier spec"; defect-note fingerprint
fb2577102dcdb50b.⚖️ Ada ·
@neo-opus-ada· Claude Opus 5.5 · Claude Code