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 e87d694
Browse filesBrowse the repository at this point in the historyBrowse files
committed
fix(store): shallow store leaves stay raw in drafts, shadows and SSR snapshots (#3498)
`{ shallow: true }` promises raw leaf references, but three projection paths
treated a shallow store as deep: `wrapDraft` wrapped every nested value read
through the derive's draft in another proxy (identity lost; an object-valued
non-configurable property on a frozen leaf tripped a Proxy invariant), and
the loading shadow, its commit copy, the SSR draft/snapshots and the
hydration replay shadow were `JSON.parse(JSON.stringify(...))` copies of the
whole tree (`Date` -> string, `NaN` -> null, `undefined` dropped, BigInt and
cycles throw).
The shallow flag now short-circuits the draft recursion (no indirect call;
the nested recursion never happens for a shallow store, so nothing is passed
down), `createDeepProxy` skips child proxies when shallow, and the copies go
through `cloneState(v, shallow)`: the root container alone for a shallow
store — its leaves are raw by contract and stay so — the tree otherwise.
The deep path is unchanged in behavior. For shallow stores every touched path
does strictly less work: no per-read proxy allocation in the draft, a root
`slice()`/spread instead of a tree clone in loading windows and hydration.
`cloneState` is mirrored in the solid server runtime rather than exported:
it is an implementation detail with an ugly contract, and the server layer
is by design a reimplementation that already carries its own copies of this
kind of logic.
The shallow half of #3499 (Leon Schiffler), reduced: the hybrid hydration
resequencing in that PR makes new rules about handoff and stays there for a
ruling. Tests are his, minus the hybrid describes; all 15 fail on unfixed
`next`. Signals, solid, web (client/server/hydrate) green. Size: hydrating
(no stores) 20,208 -> 20,260 B, hydrating + stores 30,303 -> 30,469 B, caps
ratcheted with notes; signals+store 16.65 -> 16.72 kB under cap; CSR and the
signal-only floor flat.
Co-authored-by: Leon Schiffler <[email protected]>
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
`{ shallow: true }` computed stores keep their leaves raw on every path (#3498). The projection draft no longer wraps a nested value in a draft proxy — leaf identity holds and a frozen leaf can no longer trip a Proxy invariant — and the loading shadow, its commit copy, the SSR draft and snapshots, and the hydration replay shadow copy only the root container instead of JSON-cloning the tree, which turned `Date` into a string, `NaN` into `null`, dropped `undefined` properties, and could not represent BigInt or cycles. Deep stores are unchanged.
0 commit comments