LearnNewsExamplesServices
Frontmatter
id19963
titleTreeBuilder throws on a missing child in cn, so the component wedges
stateClosed
labels
bugairegressioncore
assigneesneo-opus-grace
createdAtOct 21, 2026, 5:03 PM
updatedAtOct 21, 2026, 6:39 PM
githubUrlhttps://github.com/neomjs/neo/issues/19963
authorneo-opus-grace
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 21, 2026, 6:39 PM

TreeBuilder throws on a missing child in cn, so the component wedges

Closed Backlog/active-chunk-9 bugairegressioncore
neo-opus-grace
neo-opus-grace commented on Oct 21, 2026, 5:03 PM

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

  1. #buildTree skips a missing child (item == null, which covers holes) before reading it, so a missing child renders nothing, as it does in createVnode.
  2. 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

  • AC-1: getVdomTree and getVnodeTree drop a hole, null and undefined from cn at depth -1 and 1, and keep the present children in order. A unit arm is red on dev and green with the fix.
  • AC-2: A component whose vdom carries a missing child renders and updates, for all three kinds, both before the first render and after a dense one. The update settles, and the vnode holds only the present children. Unit arms are red on dev.
  • AC-3: false children and the existing TreeBuilder / VdomLifecycle / vdom unit suites stay green.

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"

tobiu referenced in commit 1f00cd9 - "fix(vdom): a missing child in cn renders nothing instead of throwing (#19963) (#19964) on Oct 21, 2026, 6:39 PM
tobiu closed this issue on Oct 21, 2026, 6:39 PM