Skip to content
Source
Sign inSign up
TanStack/router

solid-start: manual suspense boundaries don't transition on navigation #5636

Closedjakst(GitHub profile, opens in a new tab) opened this issue 20 comments

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

  1. Clone repo, pnpm install, start dev server, open page
  2. Click the button to increase the query param n
  3. 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

  1. @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
    	})

    https://github.com/user-attachments/assets/aeec1f7b-5f73-4b97-a104-64637b994f43

  2. @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 :)

  3. Oh wait, those were just the tests? 🤔

  4. 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?

  5. @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.

  6. @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 .latest to 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.

  7. 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.

  8. @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.

  9. @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 🤔

    Screenshot_20251030-074050.png

    Anyway, I appreciate that you're looking into this!

  10. They were only under the hood in the react version so far

  11. @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

  12. @jakst , does this work on your end?

  13. @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

  14. 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

  15. That example is with createResource. It happens with both.

  16. I tried moving your example to the ./e2e/solid-router/basic-file-based/src/routes/transition/index.tsx and that behaved better. Is this what you'd expect?

    https://github.com/user-attachments/assets/442568d1-c121-439a-8237-abb68da03f46

  17. Appear to be working with @tanstack/solid-router, but not with @tanstack/solid-start

  18. I tried moving your example to the ./e2e/solid-router/basic-file-based/src/routes/transition/index.tsx and that behaved better. Is this what you'd expect?

    Yeah, that looks better! Interesting that it's solid-start only 🤔

  19. @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.

  20. @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.