Open henriqemalheiros opened 2 years ago
Thank you for reporting the issue👍
Currently, swr ignores populateCache intentionally to avoid race conditions. So the result of the first mutation is ignored in this case.
In order to fix this avoiding the race condition problem, we might have to enqueue populateCache and apply it in the right order.
Is there an update on getting this fixed as it's a bit of a deal breaker for me using this in my project.
Bug report
Description / Observed Behavior
I'm using the
mutate
function to partially update the cached data (like this second example). When starting a second mutation before the first mutation is finished, thepopulateCache
of the first one is ignored. Because of this, when adding things to a list, the final result will be incomplete, since the first mutation couldn't update the cache.Expected Behavior
populateCache
is always called, in order in which the mutations were called.Repro Steps / Code Example
populateCache
that was called was the last one (you can check it in the console);revalidate
totrue
, the revalidation is deferred (as it should), and the list is complete. But I don't want to make an unnecessary revalidation if I have the means to sync the cached data to the latest data.Additional Context
SWR version:
2.0.0-rc.0