What causes `queryClient.invalidateQueries()` to error when all requests are good?
I wanted to add a toast-notification when doing a forced invalidation of the full cache and used this code:
The
notify.promise
function is from react-toastify
and basically just shows a message with a spinner while pending, and then switches to either the success or the error message depending on whether the promise was fulfilled or rejected.
By adding throwOnError: true
I thought this would do what I expected. Show sucess normally, and show error if any of the refetching queries failed. But seems the promise from invalidateQueries
have some other error condition causing it to fail as well?
I'm getting the error message, but when I check the console and the network log, I see no requests that have failed, all is OK. Does invalidateQueries
have a bug? Does it have a timeout of some sort? What's going on here? 🤔2 Replies
foreign-sapphire•3mo ago
what is the error message?
rival-blackOP•3mo ago
Hm... very good question... bit hard to figure out of... I'm starting to wonder if there is an error in the network log, i.e. a request that fails, but it's sporadic and kind of hidden 🥴
I'll consider this me being dumb for now, and not actually an issue, and come back with more details if it turns out I'm wrong 😆
Aaah, think I figured it out. It was my own fault. Since I'm using
refetchType: 'all'
, there are requests happening that I wasn't expecting that for other reasons will fail when I do the invalidation 🤦