You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @frederikhors - I agree this needs more visibility.
For anybody looking for an idea/solution for now, this is what I call on every app start (native; or reload in terms of our SPA for web)
constbuildKey=process.env.CODEBUILD_BUILD_IDconstbuster=`whatever-your-like-${buildKey}`constprefix='your-prefix-entry'exportconstclearStalePersistedReactQueryData=()=>{// this is needed to avoid issues with SSR rendering// prevents metro from build failingif(typeofwindow==='undefined')returnconstpersistentStoreTime=Date.now()-1*24*60*60*1000// Timestamp of 1 daystorage.getAllKeys().forEach((entry)=>{// we only want to clear the data for react-query with the prefix defined aboveif(!entry.startsWith(prefix)){return}constrawValue=storage.getString(entry)if(!rawValue)returntry{constvalue=JSON.parse(rawValue)// Check if the entry contains "buster" and if it matches the current buster// otherwise delete the entryif(value?.buster!==buster){storage.delete(entry)return}if(value?.state?.dataUpdatedAt&&value.state.dataUpdatedAt<persistentStoreTime){// Delete the stale entrystorage.delete(entry)}else{// Check if the entry contains "pages" and "pageParams"if(value.state.data&&value.state.data.pages&&value.state.data.pageParams){const{ pages, pageParams }=value.state.data// Check if the length of "pages" and "pageParams" is greater than 1if(pages.length>1&&pageParams.length>1){// Slice "pages" and "pageParams" to keep only the first entryvalue.state.data.pages=pages.slice(0,1)value.state.data.pageParams=pageParams.slice(0,1)// Update the stored value with the modified datastorage.set(entry,JSON.stringify(value))}}}}catch(error){console.error(`Error parsing JSON for key ${entry}:`,error)}})}
In case you're confused about the "pages" part. We just want to persist one page. maxPages is not working well (both problems with react-native and the persister)
Describe the bug
I'm opening this because I think this is a very important issue without a final solution.
@hirbod opened #6788 and proposed #6788 (comment).
But I think we need more discussion on this.
How often does this bug happen?
Every time
TanStack Query version
5
The text was updated successfully, but these errors were encountered: