-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR: Be able to invalidate offline data #1180
Comments
This is a pretty interesting idea. We have a feature queued up for the next release (merged in PR #1096) that adds the ability to specify a preference for get operations. We've also discussed exposing an API to delete all local storage as a kind of nuclear option. We would consider this a feature mostly for testing, but would also work in this case. There's been some discussion about this in the javascript repo but the discussion applies equally here, substituting LevelDB for IndexedDB. Meanwhile, note that the Firestore offline cache is just a LevelDB database stored as files. You can delete these before you start Firestore. You can see how we figure the directory to store them here: Note that we're investigating changing this location from I'll leave this open essentially as an iOS-specific copy of firebase/firebase-js-sdk#449. |
Does #1096 (I guess it's #655) also cover snapshot listeners or only fetches? In any case I can see why it would be considered nuclear (i.e. internal?), but I feel as if the developer needs to have some kind of control in order to escape cases such as mentioned. Will try deleting manually as suggested. Thanks. |
#655 is specifically for fetches via getDocument() / getDocuments(), but (as I think you already discovered) for a snapshot listener you can already check .metadata.isFromCache on the snapshots you get and ignore any snapshots from cache, waiting until you get a non-cache snapshot which will be fully up-to-date with the server data. If you end up wiping persistence on crashes, I'd be curious to hear how that works out for you. It does seem like this might be a useful pattern for other apps to implement and so we may want to provide some guidance and/or make it easier in the future... So if you find something that works well, let us know. |
You are correct but that would be a little bit cumbersome since:
I'm trying wiping now. Preliminary testing seems to work well, the only tricky thing is to track consecutive crashes with crashlytics - it makes more sense to clear cache after more than one consecutive crash. Will keep you posted. |
The code below seems to work well. Glad to hear your thoughts.
|
|
Consider a case where we have some kind of data discrepancy which causes crashes in our clients.
The problem is identified and fixed at our remote Firestore DB, but since clients maintain and read offline data first,
users keep processing the offline data on startup and therefore crash.
I tried playing with listening to metadata changes and ignoring offline data when the app starts after a crash, but could only do it for snapshot listeners and not for fetches.
I'd like to be able to invalidate offline data for crashing clients (i.e. in the Crashlytics delegate method).
The text was updated successfully, but these errors were encountered: