Context
test/playwright/e2e/portal/HomeAudienceDoorsNL.spec.mjs:112 fails intermittently on CI with this error:
strict mode violation: locator('#neo-container-13 .neo-viewport.neo-theme-dark') resolved to 2 elementsIt failed twice in e2e-engine (7/15): run 44480108413 on #21450 and run 44486889514 on #21458. Both were green on rerun, and both heads were unrelated to the Portal home.
Reproduced on dev at 811982dc37 in a real browser, using the component tier's Monaco fixture. A LivePreview in neomjs mode receives three native Monaco edits in one pass, and it ends with two live preview components, in 3 of 3 runs. Calling doRunSource() twice in one synchronous pass does the same, deterministically. Both components are in the container's items, and both are alive and in the DOM. This is not a ghost DOM node.
The Problem
Neo.code.executor.Neo#execute runs in this order:
- It clears the preview container.
- It starts a
Promise.all(import(…)).then(… container.add({module})) chain.
- It returns without awaiting the chain.
Each run's add lands after its imports resolve, and nothing checks whether a newer run started in the meantime. Two runs inside one import window both clear the still-empty container first, and then both add.
LivePreview#doRunSource promises to refuse obsolete runs. Its Markdown and Mermaid branches keep that promise: they check current() after every await (#8755). Its neomjs branch hands off to the executor, whose adds never consult it.
- The HomeAudienceDoors spec sets the preview's
value, which makes Monaco's setValue fire editorChange and so starts a run. It then switches to Preview, which starts a second run.
- A reader typing quickly in any live preview triggers it too, because every edit is a run. That includes the home page's two live previews (#21365).
The Architectural Reality
src/code/executor/Neo.mjs, execute(): container.removeAll(true, true) runs before the async chain. The generated code adds in .then and .catch. The method returns {} at once, so await execute() settles before the add.
src/code/LivePreview.mjs, doRunSource(): the guard is current(), which checks runSourceId, the language and the container's identity. The neomjs branch calls await me.neoExecutor.execute({code: source, container}). LivePreview is the executor's only caller.
- Design authority:
doRunSource's JSDoc: "Runs the current source through its renderer, refusing obsolete imports after a newer run, mode change or teardown."
The Fix
execute({code, container, current}): the generated chain checks current() before it touches the container, and it clears the container only when it adds. The previous result therefore stays until the new one is ready, and a stale run changes nothing. execute() returns the chain's promise, so doRunSource settles once the preview has rendered.
doRunSource passes its current to execute().
- A source that fails to parse synchronously keeps today's path: the container is cleared and shows the error.
Acceptance Criteria
Out of Scope
- Debouncing Monaco's
editorChange. Every edit still runs; only stale results are dropped.
- The Markdown and Mermaid branches, which #8755 already guards.
Avoided Traps
- Narrowing the spec's locator (for example with
.first()). That would hide a real duplicate preview.
- Debouncing the edits instead. A debounce narrows the window, but the race stays.
Related
- Vega's defect-notes on the spec: MESSAGE:8c8cbb08 and MESSAGE:b3bfb5ec, promoted here.
- #8755: the Markdown/Mermaid staleness guards.
- #21365: the home's live previews.
- #21051: nested Viewport themes.
- #21443: restores a Mermaid unit spec under
test/playwright/unit/code/. It's an adjacent path, not this scope.
Live latest-open + closed sweep: I checked the latest 20 open issues and searched open and closed (LivePreview OR "live preview", HomeAudienceDoors, LivePreview OR "live preview" executor) at 2026-11-19T10:09Z, reading #8755's ledger on the hit. No equivalent or prior exclusion found. Backlog band: 74 open (red). No open owner fits. The A2A claim sweep shows only my own [lane-intent] from 10:05Z; the Memory Core sweep found no prior sighting.
Origin Session ID: 0552507f-97b7-44bd-abca-28131c9f241a
Retrieval Hint: "LivePreview executor stale run adds second preview import window current()"
Context
test/playwright/e2e/portal/HomeAudienceDoorsNL.spec.mjs:112fails intermittently on CI with this error:strict mode violation: locator('#neo-container-13 .neo-viewport.neo-theme-dark') resolved to 2 elementsIt failed twice in
e2e-engine (7/15): run 44480108413 on #21450 and run 44486889514 on #21458. Both were green on rerun, and both heads were unrelated to the Portal home.Reproduced on
devat811982dc37in a real browser, using the component tier's Monaco fixture. A LivePreview inneomjsmode receives three native Monaco edits in one pass, and it ends with two live preview components, in 3 of 3 runs. CallingdoRunSource()twice in one synchronous pass does the same, deterministically. Both components are in the container'sitems, and both are alive and in the DOM. This is not a ghost DOM node.The Problem
Neo.code.executor.Neo#executeruns in this order:Promise.all(import(…)).then(… container.add({module}))chain.Each run's add lands after its imports resolve, and nothing checks whether a newer run started in the meantime. Two runs inside one import window both clear the still-empty container first, and then both add.
LivePreview#doRunSourcepromises to refuse obsolete runs. Its Markdown and Mermaid branches keep that promise: they checkcurrent()after every await (#8755). Itsneomjsbranch hands off to the executor, whose adds never consult it.value, which makes Monaco'ssetValuefireeditorChangeand so starts a run. It then switches to Preview, which starts a second run.The Architectural Reality
src/code/executor/Neo.mjs,execute():container.removeAll(true, true)runs before the async chain. The generated code adds in.thenand.catch. The method returns{}at once, soawait execute()settles before the add.src/code/LivePreview.mjs,doRunSource(): the guard iscurrent(), which checksrunSourceId, the language and the container's identity. Theneomjsbranch callsawait me.neoExecutor.execute({code: source, container}). LivePreview is the executor's only caller.doRunSource's JSDoc: "Runs the current source through its renderer, refusing obsolete imports after a newer run, mode change or teardown."The Fix
execute({code, container, current}): the generated chain checkscurrent()before it touches the container, and it clears the container only when it adds. The previous result therefore stays until the new one is ready, and a stale run changes nothing.execute()returns the chain's promise, sodoRunSourcesettles once the preview has rendered.doRunSourcepasses itscurrenttoexecute().Acceptance Criteria
test/playwright/component/code/LivePreview.spec.mjssends three native Monaco edits to aneomjsLivePreview in one pass. It expects exactly one preview component, showing the last edit. It fails ondevand passes with the fix.current()turns false before its imports resolve adds nothing, andexecute()settles after the current run's add.HomeAudienceDoorsNL.spec.mjsstay green.Out of Scope
editorChange. Every edit still runs; only stale results are dropped.Avoided Traps
.first()). That would hide a real duplicate preview.Related
test/playwright/unit/code/. It's an adjacent path, not this scope.Live latest-open + closed sweep: I checked the latest 20 open issues and searched open and closed (
LivePreview OR "live preview",HomeAudienceDoors,LivePreview OR "live preview" executor) at 2026-11-19T10:09Z, reading #8755's ledger on the hit. No equivalent or prior exclusion found. Backlog band: 74 open (red). No open owner fits. The A2A claim sweep shows only my own [lane-intent] from 10:05Z; the Memory Core sweep found no prior sighting.Origin Session ID: 0552507f-97b7-44bd-abca-28131c9f241a
Retrieval Hint: "LivePreview executor stale run adds second preview import window current()"