Skip to content

fix(solid): guard devComponent against undefined owner - #3005

Open
elcoosp wants to merge 1 commit into
solidjs:nextfrom
elcoosp:fix/dev-nested-root
Open

fix(solid): guard devComponent against undefined owner#3005
elcoosp wants to merge 1 commit into
solidjs:nextfrom
elcoosp:fix/dev-nested-root

Conversation

@elcoosp

@elcoosp elcoosp commented Aug 17, 2026

Copy link
Copy Markdown

Summary

devComponent (in packages/solid/src/client/core.ts) unconditionally dereferenced getOwner() and assigned owner._component, throwing "Cannot read properties of undefined (reading '[something]')" — surfacing as REACTIVITY_HALTED — whenever a component is rendered inside a root that has no enclosing owner.

This happens with a legally nested root: e.g. a component rendered inside a router's Provider/transparent root that is itself created within another owner. In dev builds this hard-crashes the entire reactive system. Production builds never hit this path.

Fix

The _component metadata is dev-only decoration. Guard it with if (owner) so it is skipped gracefully when there is no enclosing owner.

Reproduction

Render any component through a nested transparent root (createRoot(() => createRoot(() => <Comp/>, {transparent:true}), {transparent:true}), or a router Provider nested inside another root) in a dev build → devComponent throws. With the guard, it renders fine.

Scope

  • Dev builds only (devComponent is dev instrumentation).
  • No change to production behavior or public APIs.
  • 1 file changed, +12 −5.

This was found while running vitest browser-mode tests against a Solid 2.0 app where a router Provider is nested inside a test render() root.

devComponent unconditionally dereferenced getOwner() and assigned
owner._component, throwing "Cannot read properties of undefined" when a
component is rendered inside a root with no enclosing owner (e.g. a nested
transparent root created by a router or manually nested createRoot). This
hard-crashed the entire reactive system (REACTIVITY_HALTED) in dev builds.

The _component metadata is dev-only decoration; skip it gracefully when
owner is undefined. Production builds are unaffected.

Fixes a dev-mode crash when nesting roots (legal in Solid).

Signed-off-by: elcoosp <elcoosp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant