LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-ada
createdAtOct 23, 2026, 10:04 PM
updatedAtOct 26, 2026, 10:12 PM
githubUrlhttps://github.com/neomjs/neo/issues/20080
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 26, 2026, 10:11 PM

Destroy leaves config controllers live and exposes class defaults

Closed v13.4.0/archive-v13-4-0-chunk-3 bugaiarchitecturecore
neo-opus-ada
neo-opus-ada commented on Oct 23, 2026, 10:04 PM

Context

#20075 (v13.3.1, fixed by #20079): a tab header toolbar that a drop had destroyed received a late style restore from SortZone#processDragEnd. Base#destroy had deleted the toolbar's own _vdom, so the write landed in the vdom template that Neo.container.Base subclasses share. Every container created afterwards started with flex: none, and main's dock layout collapsed on the next shell rebuild. #20079 stops that writer and gives a destroyed component a private copy of its template.

The operator, on the follow-up (2026-10-23): reactive configs survive destroy because their controllers live in the private #configs, and "the destroy logic is most likely older than core.Config. destroy could remove them too, in case this is better for GC." History confirms the order: the own-key deletion dates from 2019 (8ccc8e7d7b), while core.Config and #configs arrived on 2025-07-02 (542039186c).

Measured on 2026-10-23 with a throwaway unit spec (src/Neo.mjs and src/core/Base.mjs as on dev): after destroy(), a non-reactive key reads the prototype's copy, and a write to it changes that copy. A census of component config writes after destroy (a probe in the generated setter, over the full unit suite) found:

  • isReady and isDestroying, from the destroy chain itself, everywhere;
  • vdom-touching writes: Overflow#applySplit (hidden / maxWidth / cls on destroyed tab header buttons), Button#createTooltip → addCls, grid header Button plugins and domListeners, VdomLifecycle#initVnode on destroyed containers.

Not this ticket: two live instances sharing an object-valued non-reactive default. DeclarativeConfigMerging.md documents that as the default, and per-instance mutable state belongs on reactive configs (#18192 closed not planned, D#18195 resolved, 2026-09-03).

The Problem

After destroy(), the instance is not retired:

  1. Reactive configs stay live. destroy never clears #configs, so a late set still finds its controller and runs afterSet. Each vdom-touching hook in the census writes through point 2. Clearing #configs alone would not stop it, because getConfig recreates a missing controller lazily (isConfig(key) → new Config(...)). A destroyed instance that something still references also keeps every controller and value alive.
  2. Non-reactive keys fall through to class state. destroy deletes every own writable key except destroy and _id, so the instance reads, and late code writes, the prototype copies that setupClass defines. For _vdom, that copy is the template Component#construct clones every new instance from: the #20075 path.

The Architectural Reality

  • src/core/Base.mjs: destroy (own-key deletion, then isDestroyed = true), getConfig (lazy controller), isConfig.
  • src/Neo.mjs: the generated setter (const config = this.getConfig(key); if (!config) return, the natural refusal point); setupClass (prototype copies of non-reactive defaults).
  • src/component/Base.mjs: destroy, ending with #20079's containment line me._vdom = Neo.clone(me._vdom, true); construct, which clones _vdom from the prototype.
  • Design authority: the core/Base#destroy JSDoc says it "Unregisters this instance from Neo.manager.Instance and removes all object entries from this instance". The intent is an emptied instance. Controllers that survive, and reads that fall through to class state, are side effects it does not describe. (Amended: the controllers' values stay readable on purpose, see Intake amendment; the PR adds that contract to this JSDoc.)

The Fix

Amended at intake on 2026-10-26; the derivation is under Intake amendment.

  1. The generated setter refuses every config write to a destroyed instance: no controller lookup, no hook. The private _key setter refuses too. In development, the first refused write per class and key is reported with console.warn, naming both; production refuses silently.
  2. getConfig creates no controller on a destroyed instance. The generated getter reads a config without a controller as undefined and runs no hook.
  3. The destroy chain stops writing to the destroyed instance: a repeated destroy() returns before raising isDestroying again, and the construct microtask resolves ready() for an instance destroyed before its initAsync() settled, instead of setting isReady.
  4. The controllers and their last values stay, so reads after destroy keep working. The destroy JSDoc states that contract.
  5. #20079's _vdom containment line stays as the template guard for non-config writes; the PR records whether any remain.

Intake amendment (2026-10-26)

The filed fix cleared #configs, which makes every config read after destroy answer undefined. A read census (a probe in getConfig over the full unit suite on dev 622840cce2) and a full run of that version show code depending on the last values:

  • id: ComponentManager.unregister cleans its owner index under parentComponent.id of an already destroyed parent. The DomEvent mount timeout, the grid ScrollManager addons and Compare.compareNeoInstances read it too.
  • isDestroying: state/Provider, selection/Model, selection/grid/BaseModel, grid/plugin/CellEditing and manager/transaction/History guard on it without checking isDestroyed, so an undefined read would let them run on a dead instance.
  • Delayed work and refusal paths on destroyed instances: Component#createTooltip → addCls reads cls, controller.Component#getParent reads component, and getPlugin() on a destroyed dock workspace reads plugins.

With #configs cleared, the unit suite went from 0 failed (5551 passed on dev) to 26 failed, 19 not run and 19 uncaught errors. Refusing writes alone closes the hazard this ticket exists for, a late write reaching a hook, and changes no reader.

Contract Ledger Matrix

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
config set on a destroyed instance core/Base#destroy JSDoc refused: no controller lookup, no hook; development report once per class and key — destroy JSDoc, setter comment AC-1, AC-2
config get on a destroyed instance core/Base#destroy JSDoc the last value (unchanged); a config never initialized gets no controller — destroy and getConfig JSDoc AC-1
ready() of an instance destroyed before it got ready core/Base#ready JSDoc resolves (unchanged), without the late isReady write — construct comment AC-2

Decision Record impact

none: no ADR governs instance destruction. It is aligned-with the 2026-09-03 ruling (#18192, D#18195), whose sharing semantics stay untouched.

Acceptance Criteria

Delivered by #20141, merged as 08288e206b. Each AC's evidence is in that PR's ## AC Evidence.

  • AC-1 Unit, red-first: after destroy(), a late set on a reactive key with a counting afterSet runs no hook and leaves the last value readable, a late id set registers nothing, and a config never initialized gets no controller (red on dev).
  • AC-2 Unit: in development, a late set is reported once per class and key; repeating it does not report again; outside development it is refused silently. The destroy chain's own isReady / isDestroying writes are gone, and ready() still settles for an instance destroyed before it got ready.
  • AC-3 Census, in the PR body: the post-destroy write and read census at dev and at the PR head, with a disposition for each writer (fixed here, harmless, or a follow-up).
  • AC-4 No regression: the full unit suite and the workstation/, dashboard/ and grid/ NL batteries, against the same instrument on dev.

Out of Scope

  • Sharing of object-valued non-reactive defaults between live instances (documented design; #18192, D#18195).
  • Freezing class-level defaults (it would make that documented sharing throw).
  • Fixing the census writers one by one: they go inert under item 1.
  • Releasing a destroyed instance's config values for GC: the readers under Intake amendment need changing first.

Avoided Traps

  • Clearing #configs: getConfig would recreate controllers, so late sets would still run their hooks, and every read after destroy would answer undefined (Intake amendment).
  • Silently refusing late sets: writers to dead instances would vanish from sight; the development report keeps them visible without breaking production.

Related

#20075 / #20079 (the incident and its containment), #18192 / D#18195 (the live-sharing ruling this stays clear of), Base_PrototypePollution.spec (both pollution arms).

Target: v13.4 or v13.3.2, after the v13.3.1 cut (no milestone exists yet).

Live latest-open sweep: checked the latest 20 open issues at 2026-10-23T20:03Z; no equivalent found. A2A in-flight sweep: the last 30 messages; no claim on this scope. MC sweep: 2 queries (config defaults shared across instances / prototype pollution; destroy deleting own keys / late sets / surviving controllers), 12 results. A prior decision was found and honoured: #18192 / D#18195 (live sharing is documented design), scoped out above. Own-assignment sweep: 8 open, none overlapping.

Origin Session ID: 577c5310-3173-4991-85a7-50aeabd66ceb

Retrieval Hint: "destroyed instance config controllers survive #configs getConfig recreates late set afterSet runs after destroy prototype fallthrough _vdom template"

— ⚖️ Ada · @neo-opus-ada · Claude Opus 5.5 · Claude Code

tobiu referenced in commit 08288e2 - "fix(core): a destroyed instance refuses late config writes (#20080) (#20141) on Oct 26, 2026, 10:11 PM
tobiu closed this issue on Oct 26, 2026, 10:11 PM