TRPC max retries on endpoint
Hi,
for some reason, when the api endpoint errors it reruns the request 3 times, and then on the last time if it errors again it will then emit the
onError
event. Is there a setting which I am unaware of which trys to rerun the requests x amount of times?
This results in the page loading for a number of seconds before the user is forced to login with the nextauth signIn
function.
Checking the console, the error is thrown every time. (In the picture, this is the result of one unauthorized page load)
I've had a look at the docs here: https://trpc.io/docs/v9/error-handling
and didn't see anything about a auto retry
or max retries
function/property?10 Replies
your questions isnt trpc itself
is on react query land
Query Retries | TanStack Query Docs
When a useQuery query fails (the query function throws an error), React Query will automatically retry the query if that query's request has not reached the max number of consecutive retries (defaults to 3) or a function is provided to determine if a retry is allowed.
You can configure retries both on a global level and an individual query level.
oh apologies. I was not aware trpc used react query
trpc itself is independent of rq
t3 just setup rq and the adapter for convenience (and nice usage)
oh right okay. Thank you 🙂
I'm looking for where the rq/adapter is made and I cannot find where I can configure the queryclient. i ASSUME IT IS IN
trpc.ts
after looking at the trpc docs, it appears this is where it is intialized. But cannot find any information about adding custom reactquery options.GitHub
t3-auth0/trpc.ts at main · STNeto1/t3-auth0
Contribute to STNeto1/t3-auth0 development by creating an account on GitHub.
here?
Thank you so much!
I had to insert
queryClientConfig
inside of this initaliser 🙂if you want to change the global behaviour
you can define at single query behaviour
yep. I want to change global. Useful to know that i can change specific query tho. thanks!