Unexpected behaviour with Vue Query's persist plugin: deserialize method not always called
#7783
Unanswered
nikolakrajinovic
asked this question in
Q&A
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm experiencing an issue with Vue Query's persist plugin where the
deserializemethod is not always being called as expected. This is causing inconsistent behavior in my components, as sometimes the data passed to theselectfunction is serialized, even though it should always be the return type ofqueryFn, which in my case is a Model class instance (CiDetails).Here's the relevant part of my code:
I've confirmed that the deserialize method in my
LocalStorageQuerySerializerclass is correctly implemented and should return aCiDetailsinstance. However, the debugger statement inside the select function is sometimes hit, indicating that the data is serialized, and in these cases, the debugger statement insideLocalStorageQuerySerializer.deserializeis not hit:I did notice that in these cases,
deserializeis called immediately after the firstselectcall, which hits the debugger statement insidedeserialize, after whichselectis called again with correctly deserialized data. Interestingly enough, when the data passed toselectis not an instance ofCiDetails, it is still an object, and not a string.I would expect the deserialize method to always be called before the select function, ensuring that the data is always deserialized. Is there something I'm missing, or is this a potential bug?
{ "@tanstack/query-persist-client-core": "^5.51.9", "@tanstack/vue-query": "^5.51.9" }Any help would be greatly appreciated.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions