Skip to content

DOM guard throws on insertBefore(node, undefined), which the DOM treats as append #8234

Description

@wataruY

Summary

bb wraps Node.prototype.insertBefore at startup. The wrapper only treats a reference node of exactly null as "append", so parent.insertBefore(node, undefined) throws TypeError: Cannot read properties of undefined (reading 'parentNode'). Native DOM accepts undefined there and appends. Solid 2 passes undefined, so a plugin frontend that renders with Solid crashes on its first list (<For>) insertion.

Versions and environment

  • bb desktop 0.50.1 (latest release), Linux (CachyOS, kernel 7.3.5)
  • Code cited below is unchanged on main at b0ddaad731565d7e4de68d824120d802fc78f7d5
  • No provider involved

Steps to reproduce

  1. Open any thread in bb.
  2. In DevTools, run:
    const p = document.createElement("div");
    document.body.append(p);
    p.insertBefore(document.createElement("span"), undefined);

Did not reproduce with the native method: calling the native insertBefore from a fresh iframe's Node.prototype with the same arguments appends the span.

Expected vs actual

Actual (bb page):    TypeError: Cannot read properties of undefined (reading 'parentNode')
Native (iframe):     appends, p.childNodes.length === 1

Expected: same as native. Per the DOM spec, insertBefore(node, undefined) converts undefined to null and appends.

In a plugin frontend built with Solid 2 (@solidjs/web 2.0.4) the same throw shows up as:

TypeError: Cannot read properties of undefined (reading 'parentNode')
    at HTMLUListElement.k [as insertBefore] (…/assets/index-….js)
[error] [REACTIVITY_HALTED]

and the slot is disabled by bb's crash boundary.

Evidence

  • The guard is installed unconditionally at startup: apps/app/src/main.tsx#L25
  • The null-only check: apps/app/src/lib/foreign-dom-mutation-guard.ts#L257-L271. With child === undefined, child !== null is true and child.parentNode throws.
  • Suggested fix (not tested in bb): child != null on line 261, or normalize child ?? null at the top of the wrapper.
  • Plugin-side workaround that confirms the cause: wrapping the guarded method to pass child ?? null makes the Solid 2 plugin render and update correctly.

What you ruled out

Suggested priority and effort

Low priority: it hits plugin authors whose UI library passes undefined, and a plugin-side workaround exists. Effort: low (one comparison).

Checks

  • I reproduced this on the latest release (0.50.1); the cited code is unchanged on main at b0ddaad731565d7e4de68d824120d802fc78f7d5.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

Found while prototyping a bb plugin frontend in Solid 2 (local bb thread, not public).

AGENT GENERATED

Activity

  1. added theissue type on Nov 26, 2026
  2. added
    plugins
    confirmed-repro
    on Nov 26, 2026
  3. bb-slop-cop commented on Nov 26, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: High · Effort: Low. Applied labels: plugins, confirmed-repro. No existing classification was replaced; High reflects a plugin rendering crash.
    • Verdict: REPRODUCED · root-cause confidence: high. The same investigator reproduced the failure in two clean source checkouts of trusted main.
    • Root cause: the DOM insertion wrapper checks only for null before dereferencing the reference node, so explicit undefined throws before the native append operation.
    • Reproduction and root-cause report — includes the complete regression test and exact failure output. Coverage is source-level jsdom; the full Solid plugin and released desktop package were not separately exercised.
    • Fix: PR #8238, ready for review, not merged. Two files, 35 changed text lines. Regression fails before the fix; all 66 focused/adjacent tests pass afterward. App build, lint, typecheck, formatting, and diff checks pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions