You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9034647
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(signals): prod getContext with no owner reads the context default (#4586)
In the production build, a component created outside any owner (module-scope
JSX, a timer, after an await) threw NoOwnerError from useContext even when the
context had a default; dev and observe returned the default because their
createComponent wraps each component in a root.
Fix it at the read instead of adding a root to prod createComponent: with no
owner, prod getContext now reads as if under an empty root (the default, else
ContextNotFoundError), matching what dev gives that component. Dev keeps
NoOwnerError for a bare no-owner read. createComponent is unchanged, the owned
read does the same work, and the minified getContext is a few bytes smaller.
Tests port brenelz's no-owner context-default cases (#4565): per-tier cases
against the signals prod/observe/dev artifacts, and the observe/dev and
prod-under-owner cases in solid's client artifact spec.
Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE
Co-authored-by: Claude <[email protected]>
Co-authored-by: Brenley Dueck <[email protected]>
In the production build, `getContext` (and so `useContext`) with no owner now reads as if under an empty root: it returns the context's default, and throws `ContextNotFoundError` when there is none. Before, it threw `NoOwnerError` even when the context had a default, so a component created outside any owner (JSX at module scope, in a timer or event handler, or after an `await`) crashed in production while dev and observe, whose `createComponent` runs each component in a root, returned the default. Dev still throws `NoOwnerError` for a bare read with no owner. Reads under an owner are unchanged.
0 commit comments