-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Describe the bug
When setting throwOnError: () => false, it will not refetch the query if there is an error set and there is no data
however the throwOnError: false works, but then hydrated errors via the HydrationBoundary will directly retry and wont check the hydrated error state
See this is my logic to get the error instance back again
merged.queries.forEach((query) => {
if (query.state.error) {
query.state.error = deserializeApplicationError(query.state.error);
}
if (query.state.fetchFailureReason) {
query.state.fetchFailureReason = deserializeApplicationError(query.state.fetchFailureReason);
}
});
But it only prevents a retry if i set throwOnError: () => false if i set throwOnError: false the normal behavoir of queries work again so that when there was an error fetched it will just fetch again on an mount but then the query is retried directly without it being checked against the retry: function
Your minimal, reproducible example
Steps to reproduce
- Create a Blank react query project
- Make a query with throwOnError: () => false
- Fetch an error on the very beginning (no data yet)
- Try to remount the query see it will not refetch it
Expected behavior
I want that with throwOnError: false, it should also respect the hydrated errors so that it checks it against the retry: and sees oh i dont need to retry this kind of error because retry: false, and i also did not fogot to set shouldDehydrateQuery to true if i dont want to retry the query to prevent a loading state
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
- OS: Windows
- Browser: Firefox
Tanstack Query adapter
react-query
TanStack Query version
v5.83.0
TypeScript version
v5.9.2
Additional context
No response