Replies: 3 comments 6 replies
-
How about including |
Beta Was this translation helpful? Give feedback.
-
the code looks fine. Usually when this happens, the backend doesn't consistently suppose the backend endpoint looks something like this:
if you forget the Again, the mutation code looks absolutely fine. You can double-check the network tab to see what the GET request returns. If you see "old" data over the wire, this could be it. Similarly, if the invalidation gets a response from the browser cache (not sure if you're using browser caching), the backend would never be hit for the invalidation request. For both scenarios, you will find the answer in the network tab. |
Beta Was this translation helpful? Give feedback.
-
@TkDodo I think I finally have a step-by-step recording of one scenario which is causing this behavior for us. The issue is most likely at the client side, but I don't know if I should "blame" the browser, this library, or something else yet. Maybe this added information will let you have enough context to help "point fingers"? It seems to reproduce like this:
So... are there any insights to be had here on the React Query side of things? Looking into some similar topics, I found this: #608 (reply in thread). If I read into things correctly, it essentially says that a mutation with ... all things considered, I think I may have a pretty good grip of what is going on now, and I think it is reasonable to "blame" the "promise clumping" of React Query, but as a last reach out - do you happen to have any strategies short of "do less things"/"lock down the UI while state changes are in progress" to share? |
Beta Was this translation helpful? Give feedback.
-
This is more of an issue, but not consistently reproducible, so I'm hoping to get some insights by posting here!
UPDATE: Same error happens intermittently in another context where no
initialData
is used.Main issue
Stale UI, not updating as per latest data after cache invalidation.
Key information
onSuccess
hook declaring that the loading state should not be let go until the invalidations are completed (as per https://tkdodo.eu/blog/mastering-mutations-in-react-query#awaited-promises).GET
stemming from the cache invalidation could retrieve pre-mutation data - the mutation does not return until the data stores reflect the latest state.(New simpler) Code example
We have a few queries set up using this structure (omitting most markup for brevity):
Route.tsx
Questions
Any ideas?
Any fundamental mistakes in this setup?
Really grateful for any pointers here! Thanks 🙏
Beta Was this translation helpful? Give feedback.
All reactions