Queries persisted by experimental_createQueryPersister
should be invalidated/removed as well
#9189
Unanswered
odelmarcelle
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've implemented the experimental persister in my app with the aim or re-use loading data when opening new tabs. Because there's sometimes a lot of data in the cache, the QueryClient persister turned out to be quite slow at startup. With the experimental persister, the performance is much better and thus appears to be the way to go.
However, I noticed that the persisted queries are not affected by
invalidateQueries
(if the user reloads the page) andremoveQueries
(in all cases). If nothing has subscribed to the query, it is then easily possible to enter a situation where an outdated query is returned from the persisted storage despite invalidation/removal.I believe that the invalidation behavior (setting isInvalidated) and removal behavior (removing the query from the cache) should also apply to the persisted storage.
I prepared the following CodeSandbox to highlight the issue: https://codesandbox.io/p/devbox/compassionate-james-yvg5j9
The fetched data is immediately persisted to IndexedDB. The "invalidate/removal" attempts to erase the query from the cache. However, the next click on "fetch" will return the data from the persisted cache. This is easily observed by looking at the value of
fetchedAt
.Beta Was this translation helpful? Give feedback.
All reactions