solid-start: manual suspense boundaries don't transition on navigation #5636
Which project does this relate to?#
Router
Describe the bug#
@tanstack/solid-router does not properly transition manual Suspense boundaries. I find that only the route boundaries get held up in a transition, while manual Suspense boundaries always show fallback on navigation.
Your Example Website or App#
https://github.com/jakst/tss-suspense-transition
Steps to Reproduce the Bug or Issue#
- Clone repo,
pnpm install, start dev server, open page - Click the button to increase the query param
n - Observe that Suspense fallback always triggers
Expected behavior#
I expect suspense boundaries to transition (i.e., hold the old value instead of falling back) on navigation.
Screenshots or Videos#
No response
Platform#
- Router / Start Version: 1.133.31
- OS: MacOS v15.6.1
- Browser: Chrome
- Browser Version: 141
- Bundler: vite
- Bundler Version: 7.1.12
Additional context#
No response
birkskyum(GitHub profile, opens in a new tab) closed this
@jakst , if you add placeholder data it'll look like below - does it solve the issue?
// src/routes/index.tsx const doubleQueryOptions = (n: number) => queryOptions({ queryKey: ["double", n], queryFn: async () => { await new Promise((r) => setTimeout(r, 1000)) return n * 2 }, placeholderData: (previousData) => previousData })
Yeah that seems to do it in our dashboard app as well! Looking forward to the fix landing in the next release :)
Oh wait, those were just the tests? 🤔
It's also happening with createResource, I updated the reproduction with it https://github.com/jakst/tss-suspense-transition. Would you consider reopening the issue?
birkskyum(GitHub profile, opens in a new tab) reopened this
@jakst , if you do doubleQuery.latest instead, then it shouldn't go to the fallback. I think it's reasonable to have that cache behavior be opt-in, similar to the placeholderData for query, because the single / double values are out of sync in this loading period, so the "Loading.." is technically more correct.
birkskyum(GitHub profile, opens in a new tab) closed this
@birkskyum but that goes against how Suspense works in all other contexts. The router is supposed to hold to update of the query param until the suspending resource is finished to avoid tearing. That's how it works if you load the data through route loaders, and it's also how it works if you do the same thing in Solid Start. I don't understand why this case should be different? I'm giving you trivial examples here because it's good for reproducing, but in a real world app with hundreds of async resources you have to be able to control whether something suspends or not through calling
startTransition(), not go adding.latestto every resource.Here's the Solid Start equivalent: https://stackblitz.com/edit/github-28x64bqv-xthvnizs?file=src%2Froutes%2Findex.tsx. Notice that it always transitions without fallback, since route changes are always wrapped in a transition, just like in Tanstack Start.
birkskyum(GitHub profile, opens in a new tab) reopened this
Thanks for the other repro, i see the issue now. You're very welcome to help debug it as well, so that we can get it sorted asap. I made a TransitionSuspense here i believe does what you seek by holding the values, but we have to figure how to make the Suspense behave correctly.
@jakst , there's a PR here that actually adds the ability to use transitions automatically for navigation. We're working through some failing unit tests.
@birkskyum oh that's great to hear! Although a bit surprising. This deprecation comment has led me to believe transitions were already being used under the hood 🤔
Anyway, I appreciate that you're looking into this!
They were only under the hood in the react version so far
@jakst We have transitions working for createResource/query now. It's in the new 1.134.12 release - let us know if it's working how you'd expect. It will show the fallback if there's a pendingComponent (route) or defaultPendingComponent (router) defined - otherwise it'll not show the fallback on navigating. We have added CI tests for solid-query, createResource and react-query- based on your repro
birkskyum(GitHub profile, opens in a new tab) closed this
@jakst , does this work on your end?
@birkskyum I thought so at first, but then I discovered a pretty big issue that made me have to go back to the placeholderData workaround.
Take a look at this example that I made (same repo, different branch) https://github.com/jakst/tss-suspense-transition/tree/typing
If you type quickly in the input field, it drops letters and flickers between different values. Here's a recording of me trying to type the alphabet.
https://github.com/user-attachments/assets/d45e0db2-6b5f-449a-b53b-986beb511096
Okay, so solid-query is acting up like that, which we'll have to make sure works as expected. What about the createResource? It's more thoroughly tested
That example is with createResource. It happens with both.
birkskyum(GitHub profile, opens in a new tab) reopened this
I tried moving your example to the
./e2e/solid-router/basic-file-based/src/routes/transition/index.tsxand that behaved better. Is this what you'd expect?https://github.com/user-attachments/assets/442568d1-c121-439a-8237-abb68da03f46
Appear to be working with
@tanstack/solid-router, but not with@tanstack/solid-startbirkskyum(GitHub profile, opens in a new tab) changed the title
I tried moving your example to the
./e2e/solid-router/basic-file-based/src/routes/transition/index.tsxand that behaved better. Is this what you'd expect?Yeah, that looks better! Interesting that it's solid-start only 🤔
birkskyum(GitHub profile, opens in a new tab) closed this
@jakst , there's a new release out now, that can handle navigation transitions for solid start - if you can give it a try, and let us know how it works, that would be super helpful.
My tests indicate it can handle the typing scenario with createResource. If you expect different behavior from query, a repro where it works different in another setup (e.g. with react, or solidjs/router) would be helpful as well.
@birkskyum yeah it works great now! It also fixed another issue we had that I didn't even know was related 🙂 Thanks for your work on this!
Sign in to join this conversation.
@jakst , if you add placeholder data it'll look like below - does it solve the issue?
https://github.com/user-attachments/assets/aeec1f7b-5f73-4b97-a104-64637b994f43