LearnNewsExamplesServices
Frontmatter
id18748
titleplugin.Base subscribes to `mounted` unbounded while `constructed` is bounded, six lines apart
stateClosed
labels
bugai
assigneesneo-opus-grace
createdAtSep 15, 2026, 6:51 PM
updatedAtSep 15, 2026, 8:49 PM
githubUrlhttps://github.com/neomjs/neo/issues/18748
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 15, 2026, 8:49 PM

plugin.Base subscribes to mounted unbounded while constructed is bounded, six lines apart

neo-opus-grace
neo-opus-grace commented on Sep 15, 2026, 6:51 PM

Context

#18731's three arms were reddened by three causes. The clamp is fixed, the teardown class is fixed by #18743, and @neo-opus-ada attributed the third: tab/plugin/Overflow#onOwnerMounted registers seven listeners — activeIndexChange, insert, remove, actionsChange, actionGeometryChange, actionVisibilityChange, moveTo — and the measured errors are those seven kinds, name for name, once per remount. Nothing un-registers them.

This leaf exists because the repair is in src/plugin/Base.mjs, not in #18731's dock surface, and because #18731 cannot close on it: that ticket's AC-2 and AC-4 are Neural-Link arms needing re-measurement after this lands.

Live sweeps 2026-09-15T16:5xZ: no equivalent open; #18741 and #18743 cover the teardown class, not this.

The Problem

src/plugin/Base.mjs answers the same question twice and answers it differently:

owner.on('constructed', () => { me.onOwnerConstructed() }, me, {once: true})   // bounded
owner.on('mounted', me.onOwnerMounted, me)                                     // NOT bounded

The contract is not "repeatable" — it is a coin flip on construction order. Each half has an already-true fast path:

if (owner.mounted) { me.onOwnerMounted() }        // built AFTER the mount → runs once, NO subscription
else { owner.on('mounted', …) }                   // built BEFORE → re-enters on EVERY remount

So a plugin constructed after its owner mounted never re-runs, and one constructed before re-runs forever. There is no designed re-apply behaviour to preserve — which is what decides the fix direction.

Both overrides in the tree are written as one-time setup, which corroborates it: Overflow registers listeners, list/plugin/Animate adds a resize observer and reads geometry.

Tear-out and popup-over-popup remount constantly, which is why #18731's specs surface this and ordinary specs do not.

The Fix

{once: true} on the mounted subscription, matching constructed six lines above.

The base rather than the overrides: idempotency would fix one override, would have to be written twice today, and leaves the trap for every future one. The asymmetry lives in the base.

Acceptance Criteria

  • AC-1 — a plugin constructed before its owner mounts runs onOwnerMounted once across a mount → unmount → mount cycle. Red before the change.
  • AC-2 — a plugin constructed after the mount answers the same, so the two constructor branches agree. Passes before and after by design: it is the measurement that the asymmetry existed, not a new behaviour.
  • AC-3 — onOwnerConstructed stays bounded; this must not widen the other half.
  • AC-4 — list/plugin/Animate is checked, not assumed: its observer must survive a remount under the new contract, or the fix strands it.

Out of Scope

  • Closing #18731. Its AC-2/AC-4 are Neural-Link arms that need re-running after this lands; this leaf removes their last known cause and nothing more.
  • Un-registering Overflow's seven listeners on unmount. With the subscription bounded they are registered once, so there is nothing to de-duplicate; a teardown-time un() is a different question about plugin lifetime.
  • The owner.mounted fast paths themselves. They are now consistent with the subscriptions; collapsing the four branches into two is a readability change with its own blast radius.

Avoided Traps

  • Do not make the override idempotent instead. It fixes one call site, is already needed twice, and the next override inherits the trap.
  • Do not assume {once: true} strands Animate. Measured: ResizeObserver.register de-dupes by componentId and observe() is a no-op on a known node, and addResizeObserver(false) runs only from destroy() — so the observer survives a remount. I asserted the opposite to a peer before checking; the check is one read of src/main/addon/ResizeObserver.mjs:361.
  • Do not read the two already-green arms as filler. They are the evidence that the after-mount branch already answered once, which is the whole argument for why this removes no guarantee.

Decision Record impact

none.

Related

#18731 (the ticket whose arms this reds) · #18743 / #18741 (the teardown class, the second cause) · #18554

Origin Session ID: 148d12cc-9777-46e4-bfb9-a422479153a5

Retrieval Hint: query_raw_memories("plugin Base mounted unbounded constructed once coin flip construction order")

tobiu referenced in commit a54b69e - "fix(plugin): the owner-mounted subscription is bounded, as constructed already was (#18748) (#18749) on Sep 15, 2026, 8:49 PM
tobiu closed this issue on Sep 15, 2026, 8:49 PM