Context
Found on 2026-10-20 while proving #19917 AC-3. RealWorld v1's article view wrote body.cn[1] = tagList while body.cn was still [], and the view never rendered. #19935 fixed the app side. This ticket is the engine side, promoted from defect-note f63489fa by triage. Every release since 13.0 ships it, and the Neural Link's tree reads inherit it.
The Problem
Measured on dev at ad418ae805 with a scratch script over the unit runtime (useVdomWorker: false). A hole, null and undefined all behave the same:
When the missing child appears in vdom.cn |
First render (initVnode) |
Next promiseUpdate() |
| before the first render |
TypeError: Cannot read properties of undefined (reading 'componentId'), logged |
never settles; the component never gets a vnode |
| after a dense first render (the RealWorld shape) |
ok |
rejects with the same TypeError; the vnode keeps the old children |
TreeBuilder.getVdomTree throws the same error directly, at depth -1 and 1. false passes: TreeBuilder copies it, and the vdom worker drops it.
The Architectural Reality
src/util/vdom/TreeBuilder.mjs:55-60: #buildTree reads node[childKey][i] and dereferences currentItem.componentId with no guard. Before e210054e63 (#9320, 2026-02-26, a GC-pressure change) the loop was forEach, which skips holes. Explicit null/undefined threw before that change and still do.
- The vdom worker already skips a missing child:
vdom.Helper#createVnode (src/vdom/Helper.mjs:421-433) keeps a child only if (item). util.VDom.syncVdomState (src/util/VDom.mjs:450-457) filters falsy children, but its map(item => VDom.getVdom(item)) runs before that filter, so explicit null/undefined still throw there once TreeBuilder lets them through (confirmed on the branch: with only the TreeBuilder guard, the null/undefined arms fail in VDom.getVdom).
#buildTree consumers: VdomLifecycle (first render :830, every update :622) and the Neural Link's ComponentService.getVdomTree / getVnodeTree (src/ai/client/ComponentService.mjs:339-368).
Design authority: util.VDom.syncVdomState, "The boolean check item && is critical to remove falsy values from conditional rendering and prevent runtime errors" (src/util/VDom.mjs:455-456), together with createVnode's if (item). TreeBuilder is the one walker on the render path that throws.
The Fix
#buildTree skips a missing child (item == null, which covers holes) before reading it, so a missing child renders nothing, as it does in createVnode.
- Run the explicit
null/undefined arms through a full update. If syncVdomState then throws, guard its getVdom map the same way, so the App-worker walkers on the render path share one contract.
Acceptance Criteria
Out of Scope
- Auditing every other
cn walker (ComponentManager, VDom.find, ...) for explicit null. This ticket covers the render and update path only.
- Documenting
null children as public API.
Related
- #9320 (the loop change), #19917 (where it surfaced), #19935 (the app-side fix)
- defect-note
f63489fa (2026-10-20)
Live latest-open sweep: checked latest 20 open issues at 2026-10-21T15:03Z; no equivalent found.
A2A claim sweep: latest 30 inbox rows (13:23Zā14:56Z); no claim on TreeBuilder or cn holes.
MC sweep: "Cannot read properties of undefined reading componentId vdom cn hole sparse array render throws", 6 results, no prior decision found.
Own-assignment sweep: 2 open (#19919, #15000), none overlapping.
Decision Record impact: none.
Origin Session ID: 239f49ea-d7b3-4fc4-a26d-aa940d5aefd1
Retrieval Hint: "TreeBuilder buildTree hole sparse cn componentId TypeError forEach index loop 9320"
Context
Found on 2026-10-20 while proving
#19917AC-3. RealWorld v1's article view wrotebody.cn[1] = tagListwhilebody.cnwas still[], and the view never rendered.#19935fixed the app side. This ticket is the engine side, promoted from defect-notef63489faby triage. Every release since 13.0 ships it, and the Neural Link's tree reads inherit it.The Problem
Measured on
devatad418ae805with a scratch script over the unit runtime (useVdomWorker: false). A hole,nullandundefinedall behave the same:vdom.cninitVnode)promiseUpdate()TypeError: Cannot read properties of undefined (reading 'componentId'), loggedTreeBuilder.getVdomTreethrows the same error directly, at depth-1and1.falsepasses: TreeBuilder copies it, and the vdom worker drops it.The Architectural Reality
src/util/vdom/TreeBuilder.mjs:55-60:#buildTreereadsnode[childKey][i]and dereferencescurrentItem.componentIdwith no guard. Beforee210054e63(#9320, 2026-02-26, a GC-pressure change) the loop wasforEach, which skips holes. Explicitnull/undefinedthrew before that change and still do.vdom.Helper#createVnode(src/vdom/Helper.mjs:421-433) keeps a child onlyif (item).util.VDom.syncVdomState(src/util/VDom.mjs:450-457) filters falsy children, but itsmap(item => VDom.getVdom(item))runs before that filter, so explicitnull/undefinedstill throw there once TreeBuilder lets them through (confirmed on the branch: with only the TreeBuilder guard, thenull/undefinedarms fail inVDom.getVdom).#buildTreeconsumers:VdomLifecycle(first render:830, every update:622) and the Neural Link'sComponentService.getVdomTree/getVnodeTree(src/ai/client/ComponentService.mjs:339-368).Design authority:
util.VDom.syncVdomState, "The boolean checkitem &&is critical to remove falsy values from conditional rendering and prevent runtime errors" (src/util/VDom.mjs:455-456), together withcreateVnode'sif (item). TreeBuilder is the one walker on the render path that throws.The Fix
#buildTreeskips a missing child (item == null, which covers holes) before reading it, so a missing child renders nothing, as it does increateVnode.null/undefinedarms through a full update. IfsyncVdomStatethen throws, guard itsgetVdommap the same way, so the App-worker walkers on the render path share one contract.Acceptance Criteria
getVdomTreeandgetVnodeTreedrop a hole,nullandundefinedfromcnat depth-1and1, and keep the present children in order. A unit arm is red ondevand green with the fix.dev.falsechildren and the existingTreeBuilder/VdomLifecycle/vdomunit suites stay green.Out of Scope
cnwalker (ComponentManager,VDom.find, ...) for explicitnull. This ticket covers the render and update path only.nullchildren as public API.Related
f63489fa(2026-10-20)Live latest-open sweep: checked latest 20 open issues at 2026-10-21T15:03Z; no equivalent found. A2A claim sweep: latest 30 inbox rows (13:23Zā14:56Z); no claim on TreeBuilder or
cnholes. MC sweep: "Cannot read properties of undefined reading componentId vdom cn hole sparse array render throws", 6 results, no prior decision found. Own-assignment sweep: 2 open (#19919,#15000), none overlapping. Decision Record impact: none.Origin Session ID: 239f49ea-d7b3-4fc4-a26d-aa940d5aefd1 Retrieval Hint: "TreeBuilder buildTree hole sparse cn componentId TypeError forEach index loop 9320"