Context
Found while fixing realworld2 on 2026-10-20 (#19891, #19892). Its home view rendered twice, with 23 duplicate element ids and one uncaught TypeError reading subscribe. The trigger was app-level: PreviewList, a list.Base, calls Neo.main.addon.Navigator.subscribe() in afterSetMounted (src/list/Base.mjs:343), and realworld2's addon list had dropped Navigator. #19892 restored the addon. The engine defect it exposed is still on dev: one component whose afterSetMounted throws corrupts the vdom state of its parent's subtree.
Observed: the doubled view, the 23 duplicate ids and the TypeError (realworld2 before #19892). Inferred from source, below: the mechanism. AC-1 and AC-2's red arms are its isolated reproduction.
The Problem
VdomLifecycle#syncVnodeTree hands an adopted vnode to every child component in one loop (src/mixin/VdomLifecycle.mjs:1196-1211). Setting component.mounted = true runs the child's afterSetMounted inside that loop. When it throws:
- the loop stops, so every later sibling keeps its previous vnode or none, and stays unmounted;
- the unmount pass (
:1219-1223) and the receiver's own _vnode and afterVnodeSync (:1226-1228) never run;
- the error leaves
syncVnodeTree and reaches executeVdomUpdate's catch (:502), which treats it as a failed flight. It skips the remaining roots and rejects every root's callbacks, although the main thread has already applied the deltas.
The parent's next update then diffs against a vnode tree without the nodes the DOM already holds, and inserts them again.
The Architectural Reality
syncVnodeTree (:1155) runs for each adopted root from executeVdomUpdate (:476), and from afterSetVnode (:134).
mounted is a reactive config. Components wire main-thread addons and DOM listeners in afterSetMounted (src/list/Base.mjs:330-346), so subclass and app code runs inside the loop.
- The same file already isolates callbacks that may throw, each with a try/catch and
console.error: initVnode callback rejection failed (:849), initVnode deferred update failed (:856), vdom callback rejection failed (:1107).
- Design authority: the catch's own comment, "Rejection releases every root without acknowledging a vnode it did not receive." A hook that throws after the vnode arrived and its deltas were applied is not that case.
The Fix
In syncVnodeTree's second pass, wrap each child's mount (component.mounted = true and component.afterVnodeSync(deltas)) in a try/catch that logs console.error('syncVnodeTree: a mount hook failed', component.id, error) and continues. The sync then completes: later siblings get their vnodes, the unmount pass runs, the receiver adopts its vnode, and the flight resolves.
Acceptance Criteria
Out of Scope
- The render paths that mount the rendered component itself (
:821, :1016); a throw there concerns only that component.
- App code that throws in
afterSetMounted; #19892 fixed realworld2's.
Avoided Traps
- Re-throwing after the loop:
executeVdomUpdate's catch would still reject a flight whose deltas are applied.
- Catching around
syncVnodeTree in executeVdomUpdate: the throwing child's later siblings would still stay unsynced.
Related
#19891 · #19892 (the realworld2 trigger) · #19478 (the sibling path: a mount callback that throws in initVnode must not strand later updates) · #19831 (a functional component destroyed mid-update; the same flight-settlement code)
Live latest-open sweep: latest 20 open issues at 2026-10-20T13:28Z, plus gh search issues --owner neomjs for "afterSetMounted" and "syncVnodeTree"; no equivalent (#19478 covers initVnode, not this loop)
A2A claim sweep: last 30 messages, all read-states; no claim on this scope
MC sweep: "component afterSetMounted throws, later siblings never mount, next update inserts the view twice, duplicate element ids", 6 results; only this morning's realworld2 diagnosis, no prior decision
Own-assignment sweep: 15 open; #19898/#19899 touch worker/App and the theme counter, not this loop
Retrieval Hint: "afterSetMounted throws syncVnodeTree duplicate DOM ids realworld2"
Origin Session ID: fe0fefcd-99fe-4eb2-b4c4-b8a4fbe2d92c
Context
Found while fixing realworld2 on 2026-10-20 (#19891, #19892). Its home view rendered twice, with 23 duplicate element ids and one uncaught
TypeErrorreadingsubscribe. The trigger was app-level:PreviewList, alist.Base, callsNeo.main.addon.Navigator.subscribe()inafterSetMounted(src/list/Base.mjs:343), and realworld2's addon list had droppedNavigator. #19892 restored the addon. The engine defect it exposed is still ondev: one component whoseafterSetMountedthrows corrupts the vdom state of its parent's subtree.Observed: the doubled view, the 23 duplicate ids and the TypeError (realworld2 before #19892). Inferred from source, below: the mechanism. AC-1 and AC-2's red arms are its isolated reproduction.
The Problem
VdomLifecycle#syncVnodeTreehands an adopted vnode to every child component in one loop (src/mixin/VdomLifecycle.mjs:1196-1211). Settingcomponent.mounted = trueruns the child'safterSetMountedinside that loop. When it throws::1219-1223) and the receiver's own_vnodeandafterVnodeSync(:1226-1228) never run;syncVnodeTreeand reachesexecuteVdomUpdate's catch (:502), which treats it as a failed flight. It skips the remaining roots and rejects every root's callbacks, although the main thread has already applied the deltas.The parent's next update then diffs against a vnode tree without the nodes the DOM already holds, and inserts them again.
The Architectural Reality
syncVnodeTree(:1155) runs for each adopted root fromexecuteVdomUpdate(:476), and fromafterSetVnode(:134).mountedis a reactive config. Components wire main-thread addons and DOM listeners inafterSetMounted(src/list/Base.mjs:330-346), so subclass and app code runs inside the loop.console.error:initVnode callback rejection failed(:849),initVnode deferred update failed(:856),vdom callback rejection failed(:1107).The Fix
In
syncVnodeTree's second pass, wrap each child's mount (component.mounted = trueandcomponent.afterVnodeSync(deltas)) in a try/catch that logsconsole.error('syncVnodeTree: a mount hook failed', component.id, error)and continues. The sync then completes: later siblings get their vnodes, the unmount pass runs, the receiver adopts its vnode, and the flight resolves.Acceptance Criteria
afterSetMountedthrows during its parent's update leaves its later siblings synced (vnode set,mounted: true) and the parent's vnode adopted. Red ondev.dev.Out of Scope
:821,:1016); a throw there concerns only that component.afterSetMounted; #19892 fixed realworld2's.Avoided Traps
executeVdomUpdate's catch would still reject a flight whose deltas are applied.syncVnodeTreeinexecuteVdomUpdate: the throwing child's later siblings would still stay unsynced.Related
#19891 · #19892 (the realworld2 trigger) · #19478 (the sibling path: a mount callback that throws in
initVnodemust not strand later updates) · #19831 (a functional component destroyed mid-update; the same flight-settlement code)Live latest-open sweep: latest 20 open issues at 2026-10-20T13:28Z, plus
gh search issues --owner neomjsfor "afterSetMounted" and "syncVnodeTree"; no equivalent (#19478 coversinitVnode, not this loop) A2A claim sweep: last 30 messages, all read-states; no claim on this scope MC sweep: "component afterSetMounted throws, later siblings never mount, next update inserts the view twice, duplicate element ids", 6 results; only this morning's realworld2 diagnosis, no prior decision Own-assignment sweep: 15 open; #19898/#19899 touchworker/Appand the theme counter, not this loopRetrieval Hint: "afterSetMounted throws syncVnodeTree duplicate DOM ids realworld2" Origin Session ID: fe0fefcd-99fe-4eb2-b4c4-b8a4fbe2d92c