T
TanStack2y ago
absent-sapphire

How to NOT refetch/retry failed queries?

Hello, I have some problems when fetching pararell queries. I send n number of queries and some of them might(and do) fail. The issue is that for some reason, these failed queries OCCASIONALLY get "pending" status, which is bad because I render loading state when at least one of queries is pending. In browser's network tab I see that I refetch these previously failed requests, but don't wanna do that. How can I achieve it?
useQueries({
combine: (results) => {...},
queries: dates.map<UseQueryOptions<SlotsSuggestionsResponse>>((date) => ({
queryKey: [date, meeting_type, userAddress, user_id],
queryFn: () => {
return get_slot_suggestions(
userAddress,
meeting_type,
date,
user_id
);
},
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
enabled: !!customerData && !!meeting_type && !!dates?.length,
retry: false,
})),
});
useQueries({
combine: (results) => {...},
queries: dates.map<UseQueryOptions<SlotsSuggestionsResponse>>((date) => ({
queryKey: [date, meeting_type, userAddress, user_id],
queryFn: () => {
return get_slot_suggestions(
userAddress,
meeting_type,
date,
user_id
);
},
refetchOnMount: false,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
enabled: !!customerData && !!meeting_type && !!dates?.length,
retry: false,
})),
});
What might be the cause of that?
3 Replies
foreign-sapphire
foreign-sapphire2y ago
Maybe checkout query devtools
itchy-amethyst
itchy-amethyst17mo ago
- make sure retry is globally set to false - React Query caches the results of successful queries and considers them as "stale" after a certain period of time (default is 0), you can try setting staleTime to someth that doesn't make the queries stale too quick
conscious-sapphire
conscious-sapphire13mo ago
tried this already but still refetching when the request failed

Did you find this page helpful?