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
{{ message }}
Repository navigation
Add a default retry handling to avoid retry on specific TRCP errors #1714
I just found that with default settings when using the react client, the query is retried 3 times despite the server sending an UNAUTHORIZED error. I think a default could be to only retry in this cases:
queries: {retry(failureCount,_err){consterr=_errasneverasTRPCClientErrorLike<AppRouter>;constMAX_QUERY_RETRIES=3;constcode=err?.data?.code;if(code==='NOT_FOUND'||code==='BAD_REQUEST'){// prevent refetch on queries that always will failreturnfalse;}returnfailureCount<MAX_QUERY_RETRIES;},},
The default behavior of retrying on error is strange to me. Most errors don't resolve automatically. The only error I can think of that should be retried is if the network connection was interrupted.
The current mechanism is problematic for a user since they have to wait for all retries to fail until the app can show the error. This is clearly not desired for errors like 400 Bad request, 401 Unauthorized, 404 Not found. In these cases, we'd rather show the user directly what the problem was so that they can fix it.
Activity
jlalmes commentedon Mar 30, 2022
Like this idea, I'm also not sure how to best handle retrying after an
INTERNAL_SERVER_ERRORerror.KATT commentedon Apr 1, 2022
I think I don't want it in the library, but I want the examples to showcase a production-ready version, so it would be good to have some more sensible defaults in here: https://github.com/trpc/trpc/blob/main/examples/next-prisma-starter/src/pages/_app.tsx#L74
KATT commentedon Apr 1, 2022
Idea:
ViktorQvarfordt commentedon Jul 30, 2022
The default behavior of retrying on error is strange to me. Most errors don't resolve automatically. The only error I can think of that should be retried is if the network connection was interrupted.
The current mechanism is problematic for a user since they have to wait for all retries to fail until the app can show the error. This is clearly not desired for errors like 400 Bad request, 401 Unauthorized, 404 Not found. In these cases, we'd rather show the user directly what the problem was so that they can fix it.
ViktorQvarfordt commentedon Jul 30, 2022
Is it possible to completely disable the retry mechanism until something more flexible is put in place?
KATT commentedon Jul 30, 2022
See the message above, you can customize the behavior fully
ArnaudBarre commentedon Jul 30, 2022
Yes it's easy do disable react-query behaviour. For now I ended up using:
github-actions commentedon Oct 4, 2022
This issue has been locked because it had no new activity for 14 days. If you are running into a similar issue, please create a new issue. Thank you.