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 7f9bd7a
Browse filesBrowse the repository at this point in the historyBrowse files
committed
lazy() preload/moduleUrl and getTraceContext resolve the caller's render, not the global context
`lazy()`'s `preload()` and `moduleUrl` getter, and `getTraceContext()`
outside a request scope, read the module-global `sharedConfig.context`.
That is whichever render started or finished last. So under concurrent
requests a call made outside the component's own render pass landed in
another request's render:
- `preload()` from a route data function, or from code after an `await`,
put this request's modulepreload/stylesheet/preload links into another
request's head. This page missed them.
- a `moduleUrl` read there resolved through the other render's manifest
and filed its modulepreload hint there, and a read after a
`renderToString` finished resolved through that render's lingering
context
- an unscoped `getTraceContext()` after an `await` returned the render
that last took the global
In real apps, Solid Router calls `component.preload()` synchronously in
`createRouteContext` during render, which was already attributable. The
leaking paths are user code run outside render: route `preload` data
functions run by `createFlightDataCollector` after its
`await resolveLazyMatches(...)` (Solid Start's server-function
single-flight path), and anything after an `await` in an async memo.
Solid Start's `withRouteAssets` forwards `preload`/`moduleUrl` to the
lazy component unchanged.
Both now resolve the render through the caller's owner, walking to the
root the renderer claimed in the render-root table added for
`getRequestEvent`. solid-js's server entry reads that table directly
through the registered symbol, so there is no new export. A call no
render can be attributed to hints nowhere: the import still starts and
the component's own render registers its assets when it mounts.
`moduleUrl` returns the raw specifier and `getTraceContext()` returns
`undefined`. The render path's own context read (the component body,
captured at creation inside a pass like every server primitive) is
unchanged.
A render's `"render"` observe record settles off its pass, after the
string root returned or from the stream's completion. It now settles
under the render's root owner, so a listener reading `getTraceContext()`
from its callback still finds its own render's trace.
concurrent-render-lazy-assets.spec.tsx and concurrent-render-trace.spec.tsx
interleave two renders with per-request manifests. The seven leak cases
fail on the parent commit: preload and moduleUrl with and without the
owner, moduleUrl after a finished string render, and trace reads with
and without the owner. Four guards pass on both: preload in its own
render pass, and the string, piped stream and awaited stream listeners.
In nohydration.spec.ts, a unit case for a foreign global context fails
on the parent too. The solid unit tests that modelled a render by setting
the global now run their preload/moduleUrl calls inside a claimed root
(test/server/render-root.ts).
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
`lazy()`'s `preload()` and `moduleUrl`, and `getTraceContext()` outside a request scope, resolve the caller's own render instead of the global SSR context
7
+
8
+
Both read the module-global `sharedConfig.context`, which is whichever render started or finished last. A `preload()` or `moduleUrl` read made outside the component's own render pass (a route data function, code after an `await`) registered its modulepreload/stylesheet hints into, and resolved its URL through the manifest of, whatever render held the global, possibly another concurrent request's page. An unscoped `getTraceContext()` read the same way could return another render's trace. Both now resolve the render through the caller's owner, walking to the render root the renderer claimed. A call no render can be attributed to hints nowhere, and `moduleUrl` returns the raw specifier and `getTraceContext()` returns `undefined`. The component's own render still registers its assets when it mounts. A render's `"render"` observe record settles under the render's root owner, so its listener still reads that render's trace.
0 commit comments