TanStackT
TanStack9mo ago
1 reply
nursing-lime

Route preloading causing an infinite loop.

I'm running into an issue with route preloading causing an infinite loop.
I'm using tanstack start and have a server function fetchSessionUser() that's used in my root route's beforeLoad to get the current user from supabase.

When I hover over a <Link to="/teams/create" />, which is located in /_authed/dashboard (route: _authed/teams/create.tsx) , tanstack tries to preload the /teams/create route, and that seems to trigger the root beforeLoad (and therefore the fetchSessionUser() serverFn) repeatedly, leading to an infinite loop of requests like this in the terminal:
ServerFn Request: src_routes_authed_tsx--fetchSessionUser_createServerFn_handler
ServerFn Response: 200
...
(infinite loop)
63D39A76-54E1-4EE4-99C5-8ED6C971C6CA.png
59E73B46-8256-49B5-A898-D755BA053D5D.png
B4161E3C-E01F-4BDE-836B-C12B70BD7A1B.png
Was this page helpful?