Persister writing every 1 second
Hello,
I just noticed that my persister is writing every one second with the only difference being
timestamp. I narrowed it down to a "DigitalClock" component that I have:
The 1 second cadence makes sense, but what doesnt make sense is why react-query tries to write to the cache every time. If I comment out the component then react query stops writing every second!9 Replies
optimistic-goldOP•3y ago
Let me give a bit more code/clarity
and the query from
useBuildHooks looks something like this:
I was thinking maybe because setTime causes a re-render which causes the useQuery hook to re-evaluate, but I also don't think that should be the casegenetic-orange•3y ago
it's because observer options are updated. We have a PR to ignore these events
complex-teal•3y ago
Looks like setTime’s rerender to me
genetic-orange•3y ago
GitHub
perf(persist): subscriber calls persistQueryClientStore only on cac...
By default persistQueryClientSubscribe was calling persistQueryClientSave on every single change in query cache.
It was also triggered by events like observerOptionsUpdated which are emitted very o...
rare-sapphire•3y ago
This ☝️ we're working on it 🙂
optimistic-goldOP•3y ago
Awesome, thanks so much!!
Any update on this? Seems like the tests are missing
stormy-gold•3y ago
I should add missing test this week hopefully, sorry for the delay
In the meantime I’ll share with you a snippet which you can safely use to set it up by yourself when I’m at my desk
Maybe you can find sth helpful in this thread:
https://discord.com/channels/719702312431386674/1067399193255231499/1068138769808629811
@TkDodo 🔮, @Louis I just added missing test:
https://github.com/TanStack/query/pull/4884/commits/2b44c28bf872048d2180f9df8b2e5a1ff0e36bf5
Sorry for the delay!
genetic-orange•3y ago
thanks for this - great job 👏 . I just merged the PR 🚀
stormy-gold•3y ago
Aaaawsome! 🥳