T
TanStack2y ago
harsh-harlequin

Query does not retry on fail

I have the following setup and query. I am trying to fetch data every 30 seconds. If the fetch fails, I want it to retry every 60 seconds with exponential backoff which caps off at 10 minutes. The refetch on success (refetchInterval) is working fine, it is just the retryDelay that isn't working.
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retryDelay: (attemptIndex) => Math.min(60_000 * 2 ** attemptIndex, 600_000),
retry: 6,
},
},
})
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retryDelay: (attemptIndex) => Math.min(60_000 * 2 ** attemptIndex, 600_000),
retry: 6,
},
},
})
const {data} = useQuery({
queryKey: // queryKey,
queryFn: // some queryFn that throws an error if data is null,
enabled: !!id,
refetchInterval: 30_000,
})
const {data} = useQuery({
queryKey: // queryKey,
queryFn: // some queryFn that throws an error if data is null,
enabled: !!id,
refetchInterval: 30_000,
})
I can clearly see that it is throwing an error on my browser, but it is not retrying (I cannot see any new network requests). Why isn't it working?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?