TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.19k stars 486 forks source link

A component suspended while responding to synchronous input in version 1.31.9 #1554

Closed jmargeta closed 2 weeks ago

jmargeta commented 2 weeks ago

Describe the bug

Hi, thanks for the excellent library! After the update to the latest 1.31.9 we are getting: "A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition."

Is there any migration strategy to use this version (all works perfectly with 1.31.8)?

Your Example Website or App

-

Steps to Reproduce the Bug or Issue

  1. Update to 1.31.9

Expected behavior

App loads

Screenshots or Videos

image image

Platform

Additional context

No response

tonywei92 commented 2 weeks ago

@anyone Use this repo to reproduce: https://github.com/tonywei92/tanstack-react-router-sample-error-1.31.9

aromko commented 2 weeks ago

Hey. I got the same error after upgrade. How can it be fixed?

jmargeta commented 2 weeks ago

The stackblitz example for authenticated routes seems to be currently broken as well: https://tanstack.com/router/latest/docs/framework/react/examples/authenticated-routes image

kaulshashank commented 2 weeks ago

Facing the same issue here +1. Was attempting to replicate the authenticated-routes example in a new repo.

@jmargeta what version did you upgrade from? I am new to using this project and want to switch to a version where this wasn't happening.

Can confirm it's not happening on v1.31.7

j3sch commented 2 weeks ago

I get the same error. For me the issue was: @tanstack/router-devtools": "~1.31.1", I just removed the tilde, now everything works again

tforssander commented 2 weeks ago

Same issue here, downgrading @tanstack/react-router from 1.31.9 to 1.31.8 seems to resolve the issue.

jmargeta commented 2 weeks ago

A new release 1.31.10 seems to fix this (https://github.com/TanStack/router/commit/036c12ea72c9930e3b7b6ac8e74df508402fd65a)

Thanks a lot, @tannerlinsley, you are incredible!

tonywei92 commented 1 week ago

@jmargeta still error on my side, tried install the latest version 1.31.23

mstosio commented 1 week ago

Still facing this issue with latest version

jmargeta commented 1 week ago

@stosio, is it still an issue for you after the latest release? Shall I reopen this issue?

mstosio commented 1 week ago

@jmargeta Yesterday, I was configuring a router from scratch based on the documentation and encountered the same issue. Is it possible that the fix hasn't been published yet?

visualjerk commented 4 days ago

This error still occurs with the latest version 1.32.5, please reopen the issue.

Workaround: Wrap the RouterProvider in a Suspense

<Suspense>
  <RouterProvider router={router} />
</Suspense>
TkDodo commented 3 days ago

can you show a reproduction please?

the mentioned example about authenticated routes works fine:

https://tanstack.com/router/v1/docs/framework/react/examples/authenticated-routes

visualjerk commented 2 days ago

Sure, it looks like the issue occurs in combination with Tanstack Query. Here is a minimal reproduction example:

https://stackblitz.com/edit/tanstack-router-uwrknv?file=src%2Fmain.tsx

As this combination is different from the initial bug description, should I rather create a new issue for it?

TkDodo commented 2 days ago

@visualjerk you're calling useQuery outside of the RouterProvider, which I'm not sure why you would do that?

I think with TanStack router, the only thing you should be rendering in root.render is:

<RouterProvider router={router} />

and then the rest should go into the root layout.

visualjerk commented 2 days ago

In our case, we just needed a route independent place to use this query. Putting it in the root layout is a good alternative, thanks for the clarification!