How to disable retries when network request is cancelled?
I have a situation where I need to imperatively call queryClient.fetchQuery() to fetch data. Sometimes the network request from this query get cancelled by Chrome where the network status is "(canceled)" (see image). Is there a way to disable retries when this happens? Thank you!

3 Replies
harsh-harlequin•10mo ago
How about a retry function? This is pseudo code obviously.
sensitive-blue•10mo ago
yeah this is how you'd do it. If you know the error is a "canceled" error (not sure if we get that from fetch), then you can implement a retry function that checks for that. That's exactly why retry can be a function 🙂
fascinating-indigoOP•10mo ago
Thanks all. The above is what I tried to do at first. For some reason, the
retry
hook isn't being called when this happens. The client doing the fetching is a custom wrapper around Axios. I need to dig in more to see why the error thrown by it is not triggering retry
.