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
If that query fails, I would like to not run any operations whatsoever. I would like for any client-side mounted queries to not trigger refetches at all
constApplicationLayout=({
children,}: LayoutProps<"/app">|LayoutProps<"/admin">)=>{prefetch([trpc.admin.me.queryOptions(undefined,{retry: false,}),]);return(<HydrateClient> // Btw HydrateClient is just this: https://github.com/t3-oss/create-t3-turbo/blob/main/apps/nextjs/src/trpc/server.tsx#L35-L42
{children}</HydrateClient>);};exportdefaultApplicationLayout;
And then I have a hook that is used in almost ALL pages (except for the auth page for example):
"use client"exportconstuseAdminUserData=()=>{consttrpc=useTRPC();constquery=useQuery(trpc.admin.me.queryOptions(undefined,{enabled: false,//Notice the enabled:false and the retry: falseretry: false}),);//...More implementation here. (I have custom logic to manually refetch this data)returnquery;}
I want to have this pattern for the sole reason that pretty much 100% of the pages need the admin.me query. However, if you are not logged in, then this query fails. I CANNOT conditionally call this based on authentication because I am using Next.JS cacheComponents, and I don't want to make my entire application (from this layout) be under a <Suspense> boundary.
This setup with retry: false in the queryOptions is not working, and the client-side query client ALWAYS is causing additional retries on the client side, which I do not want.
This is what happens in the auth page:
If I remove the prefetch in the RSC, then there's no fetching happening at all and no errors/no retries. (But this is not what I want since I want the prefetch, obviously)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to understand how I can:
And then I have a hook that is used in almost ALL pages (except for the auth page for example):
I want to have this pattern for the sole reason that pretty much 100% of the pages need the
admin.mequery. However, if you are not logged in, then this query fails. I CANNOT conditionally call this based on authentication because I am using Next.JS cacheComponents, and I don't want to make my entire application (from this layout) be under a<Suspense>boundary.This setup with
retry: falsein the queryOptions is not working, and the client-side query client ALWAYS is causing additional retries on the client side, which I do not want.This is what happens in the auth page:

If I remove the prefetch in the RSC, then there's no fetching happening at all and no errors/no retries. (But this is not what I want since I want the prefetch, obviously)
Beta Was this translation helpful? Give feedback.
All reactions