LearnNewsExamplesServices
Frontmatter
id18319
titleA destroyed Workspace still fires a pending admission's expiry timer
stateClosed
labels
bugaitestingdashboard
assigneesneo-opus-vega
createdAtSep 4, 2026, 8:18 PM
updatedAtSep 4, 2026, 9:41 PM
githubUrlhttps://github.com/neomjs/neo/issues/18319
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 4, 2026, 9:41 PM

A destroyed Workspace still fires a pending admission's expiry timer

Closed v13.2.0/archive-v13-2-0-chunk-19 bugaitestingdashboard
neo-opus-vega
neo-opus-vega commented on Sep 4, 2026, 8:18 PM

Context

Seen twice in a row while running the full unit suite for #18297 on dev 131c782ca8 plus a lifecycle-only change that touches neither seam (2026-09-04 17:49Z and 17:52Z, npm run test-unit -- --workers=1): 3211 passed, 1 failed, a different victim each run — main/addon/ResizeObserver.spec.mjs:262, then main/addon/NativeDragSource.spec.mjs:176 — both with

TypeError: Cannot read properties of undefined (reading 'get')
  at HostOpenerWorkspace.expireTearOutAdmission (src/dashboard/dock/Workspace.mjs:718:48)
  at Timeout._onTimeout (src/dashboard/dock/Workspace.mjs:682:20)

Both victims pass alone (ResizeObserver 24/24 across three runs). HostOpenerWorkspace is a fixture of test/playwright/unit/dashboard/DockWorkspace.spec.mjs — the arm "a host override is the ONLY opener that runs" (:3719) — and the victim is whichever spec is executing about 20 s later, roughly 740 tests on under --workers=1. The unit job of the same head was green on CI (run 33900510596); the local serial run reds one random main/addon spec every time. Observation and inference are separated below: the stack is observed; the 20 s arithmetic is the timer's default.

The Problem

acquireTearOutVessel (:589) records an admission, arms its expiry — admission.timerId = setTimeout(() => me.expireTearOutAdmission(itemId, admission), me.tearOutConnectWindowMs) (:680–683, default 20000 ms) — and, when the host opener answers, records the opened vessel's windowName on that admission (:674), all regardless of enableDockTearOutLifecycle (default false, :282–284). destroy() (:1637) settles tear-out state through retireTearOutState() (:1515) — which closes every admission's vessel through closeTearOutVessel (:1516–1537) and clears every admission's timer via clearTearOutAdmission (:1545, :699–704) — but only inside if (me.enableDockTearOutLifecycle) (:1640). A workspace that acquired a vessel with the lifecycle off is therefore destroyed with its timer armed AND its opened vessel unclosed. core.Base#destroy then deletes every writable own property (src/core/Base.mjs:531–535), so when the timer fires, expireTearOutAdmission (:713) reads me.tearOutAdmissions.get(itemId) on an instance that no longer has the field. The callback runs inside a timer, so the TypeError is an uncaught exception: in a unit run Playwright charges it to whatever test is executing; in an app it is a stray error in the App Worker console about 20 s after a dashboard with a still-opening pop-out was destroyed — and the pop-out's window stays open with nothing owning it.

The Architectural Reality

  • The admission is ADR 0029 §2.8.3's vessel-admission contract: a token, a connect window, an expiry that closes a vessel that never connected. The admission — its timer, its record, and the native vessel it opened — is one ownership unit, owned by the instance that armed it; nothing else can retire it.
  • retireTearOutState already retires that unit whole. The gap is the gate in front of it: the lifecycle flag guards the worker connect/disconnect subscriptions AND the whole retire, while acquireTearOutVessel / the engine default openTearOutVessel (which needs only useSharedWorkers) run without it.
  • onWindowDisconnect (:1469) early-returns on isDestroyed; expireTearOutAdmission has no such guard.
  • #17990 (closed) guards destruction WHILE openTearOutVessel() is still awaited (:633–656); it does not cover destruction after that await has returned a vessel. (Review correction on PR #18323, @neo-gpt.)

The Fix

src/dashboard/dock/Workspace.mjs:

  1. destroy(): run retireTearOutState() unconditionally — the vessels, admissions (timers included) and owner-held panes this instance owns retire whether or not it opted into the lifecycle; only the worker connect/disconnect unregistration stays under enableDockTearOutLifecycle, because only the opt-in subscribed. (retireTearOutState already clears every admission's timer, so no separate sweep.)
  2. expireTearOutAdmission: if (me.isDestroyed || admission?.connected) return; — the guard onWindowDisconnect already has, against an expiry already queued when the instance went away.

No signature, config, or event changes.

Contract Ledger Matrix

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
Workspace#destroy (:1637) / #expireTearOutAdmission (:713) ADR 0029 §2.8.3 (vessel lifecycle and admission); retireTearOutState (:1515) a destroyed workspace holds no armed admission timer and no unclosed vessel it opened: the admission's timer, record and vessel retire together, lifecycle opt-in or not; an expiry that fires on a destroyed instance is a no-op; the worker listener unregistration stays the opt-in's — destroy() docblock; expireTearOutAdmission docblock red-first unit arm in unit/dashboard/DockWorkspace.spec.mjs with a close-seam witness; two consecutive full unit runs without the stray TypeError

Decision Record impact

aligned-with ADR 0029 (§2.8.3) — restores the lifecycle's teardown invariant; no contract change.

Acceptance Criteria

  • AC-1 Red-first unit arm in test/playwright/unit/dashboard/DockWorkspace.spec.mjs: a PlainWorkspace (lifecycle off) with tearOutConnectWindowMs: 20 acquires a vessel through a host opener, is destroyed while the admission is pending, and the arm waits past the window — on dev today the wait ends in TypeError … reading 'get' at Workspace.mjs:718 and the opened vessel is never closed; with the fix nothing fires and the host's close seam receives that vessel's windowName exactly once.
  • AC-2 The existing "a host override is the ONLY opener that runs" arm (:3719) no longer leaves a timer behind: two consecutive full unit runs (npm run test-unit -- --workers=1) show no expireTearOutAdmission stack in any spec.
  • AC-3 With the lifecycle ON, behaviour is unchanged: the #17681 engine tear-out lifecycle matrix arms stay green, and the retire runs once.

Out of Scope

  • Whether acquireTearOutVessel should refuse to arm an admission while the lifecycle is off — a product decision about the action path; today the engine default opener needs only useSharedWorkers.
  • #17990's destroy-during-open guard (closed, unchanged).
  • The tear-out cluster's relocation under #18304 (#18311, #18317): this is a small fix on the code as it stands; a move carries it along.

Related

#17990 (destruction while the open is awaited) · #18297 (the runs that surfaced it) · #18311 / #18317 (the cluster this code is about to move with) · #18275 (a different flaky-red class the same runs showed) · ADR 0029 §2.8.3 · PR #18323 (the fix; @neo-gpt's review widened the ledger from the timer to the whole admission).

Live latest-open sweep: latest 20 open issues read at 2026-09-04T18:17:47Z (#18317 … #18284) — none equivalent; #18317 and #18311 touch the same cluster, not this defect. A2A claim sweep: last 30 messages, all read-states, 16:26–18:12Z — no claim on this scope; my own defect-note (17:53Z) is the only mention. KB semantic sweep (type: ticket): nearest #16498 and #15874 (a destroy-before-initAsync lifecycle leak — same family, different timer); no equivalent.

Origin Session ID: 007aac9d-974a-465c-9015-378aeb741bd5

Retrieval Hint: query_raw_memories("destroyed Workspace expireTearOutAdmission timer tearOutAdmissions undefined full unit run ResizeObserver NativeDragSource")