-
In my app I use mostly useQuery hook, but in few places queryClient.fetchQuery is needed. I use the same retry options and queryFn in all cases. I noticed that while with useQuery hook retry works just fine, fetchQuery doesn't catch errors in queryFn, so retry doesn't happen. According to the docs I expect retry to just work in queryClient.fetchQuery. What do I misunderstand? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
retry should happen because it's an internal thing. There is an explicit code check though: that references this issue: I'm not really sure if the implementation is correct. Judging from the comments, it seems like we wanted to turn off default retries for Looking at the PR, which was made for v2, this used be in the prefetching function, but potentially regressed in the v3 rewrite: I would accept a PR that moves this logic to the prefetchQuery function with the necessary tests. Would you like to contribute? In the meantime, passing retry explicitly should also work:
|
Beta Was this translation helpful? Give feedback.
retry should happen because it's an internal thing. There is an explicit code check though:
https://github.com/tannerlinsley/react-query/blob/f53d8b18c0396dee1052b3bbdbbf3e68b589dc99/src/core/queryClient.ts#L361-L364
that references this issue:
#652
I'm not really sure if the implementation is correct. Judging from the comments, it seems like we wanted to turn off default retries for
prefetchQuery
, but instead did it onfetchQuery
- which also works for prefetching, becauseprefetchQuery
just callsfetchQuery
internally.Looking at the PR, which was made for v2, this used be in the prefetching function, but potentially regressed in the v3 rewrite:
#760
I would accept a PR that moves this …