Option to cache errors #1772
Unanswered
CreativeTechGuy
asked this question in
Ideas
Replies: 1 comment 11 replies
-
You could catch your error in the queryFn and transform it to a resolved promise in case of an error you’d like to cache, and re-throw all other errors, but the error will then show up in data, so you’d have to model your structure accordingly. you can also implement the retry function to prevent retries for certain errors. converting this to a discussion because it’s a feature request, not a bug. We can definitely keep discussing there :) |
Beta Was this translation helpful? Give feedback.
11 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
Some errors from APIs are non-retryable and should be cached. When they are not, then the component will try to continuously re-make the call every time a component is mounted even though we know that it'll fail again. Depending on the structure of the app this could create infinite loops in the worst case or make tons of unnecessary API calls in the most likely case.
To Reproduce
Steps to reproduce the behavior:
useQuery
and returns an error.useQuery
will retry and get the same error.Expected behavior
There should be a query option to cache errors. Either a boolean to indicate that all errors should be cached using the normal rules, but also a function which is passed the error and can return true/false to indicate if that specific error should be cached. (So a user can differentiate between a non-retryable error and a retryable error.)
Screenshots
N/A
Additional context
N/A
Beta Was this translation helpful? Give feedback.
All reactions