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
When a resource is created outside of the <Suspense> boundary that wraps its data access, the first such resource will not have related onCleanup functions triggered on the server (only the first resource created this way).
Kind of nuanced, and there seems to be some other strange but related behavior at play here as well. Easier to show with some examples.
Here's our resource helper - it just creates and returns a new resource, and registers an onCleanup function:
Reload the page, view server-side logs in terminal
Expected behavior
onCleanup is called consistently.
Screenshots or Videos
No response
Platform
OS: na
Browser: na
Version: 1.6.12
Additional context
Originally ran into this behavior while trying to debug an issue in @tanstack/solid-query. onCleanup is used there to unsubscribe various observables, and the fact that it is not called consistently when on the server is causing problems.
The text was updated successfully, but these errors were encountered:
It is expected. On the server we execute more like React. There is no real reactivity. So Suspense boundaries will re-run. It's just so much faster to concat strings than it is to have creative primitives in memory for this case. That being said we do remember that it was created so we don't fetch again.
Describe the bug
When a resource is created outside of the
<Suspense>
boundary that wraps its data access, the first such resource will not have relatedonCleanup
functions triggered on the server (only the first resource created this way).Kind of nuanced, and there seems to be some other strange but related behavior at play here as well. Easier to show with some examples.
Here's our resource helper - it just creates and returns a new resource, and registers an
onCleanup
function:https://github.com/marbemac/solid-oncleanup-ssr-bug/blob/ef6a572b581791ccabaf6439061b70d6e0c59e91/src/routes/index.tsx#L25-L39
A
DataComp
component that does not include it's own suspense boundary:https://github.com/marbemac/solid-oncleanup-ssr-bug/blob/ef6a572b581791ccabaf6439061b70d6e0c59e91/src/routes/index.tsx#L41-L51
A
DataCompWithInnerSuspense
component that DOES wrap access to the resource data in its own suspense boundary:https://github.com/marbemac/solid-oncleanup-ssr-bug/blob/ef6a572b581791ccabaf6439061b70d6e0c59e91/src/routes/index.tsx#L53-L67
Scenarios
Render a single
DataCompWithInnerSuspense
Resulting server logs
Note no
onCleanup
.Render more than one
DataCompWithInnerSuspense
Resulting server logs
Note the second comp did have it's
onCleanup
triggered.Render
DataComp
+ one or moreDataCompWithInnerSuspense
Resulting server logs
In this case
onCleanup
IS called forDataCompWithInnerSuspense-1
.Note however that there might be some other weirdness, not sure why the the
DataComp
logs are triggered again at the end (last 4 lines).Your Example Website or App
https://github.com/marbemac/solid-oncleanup-ssr-bug
Steps to Reproduce the Bug or Issue
pnpm install
pnpm dev
Expected behavior
onCleanup
is called consistently.Screenshots or Videos
No response
Platform
Additional context
Originally ran into this behavior while trying to debug an issue in
@tanstack/solid-query
.onCleanup
is used there to unsubscribe various observables, and the fact that it is not called consistently when on the server is causing problems.The text was updated successfully, but these errors were encountered: