mobx-persist
mobx-persist copied to clipboard
Detecting crashes from restored state
Hi There,
Not sure if this have come up yet but if my app crashes within a short amount of time of running hydrate I'd like to clear all the persistence. Seems like a useful feature for obvious reasons, what do you thing?
Close if you can't help! I'm really impressed with how well this library is working with react-navigation!
React Native Android? Can you provide your crash logs?
Sorry to have not made myself clear: I want a feature that every time the App crashes within 200ms of a hydrate I can clear that hydrate information. The reason I want this is if the App gets into a persistent crashing state there will be no way to recover. Does this make more sense as a feature request rather than an issue with your library?
OK, I understand now. You mean that some wrong persisted data will cause some JS errors, then this wrong data should be deleted. You can try this:
hydrate('some', someStore).catch(e => {
console.warn(e)
// TODO: delete the state
})
Yes perfect start, just wondering if the catch will always fire or if there will be a small delay or another part of the application when receiving this information will crash?
I can confirm the repopulation of the state crashes the App if it's bad or undefined even with the suggested catch in place upon hydrate. I'm going to need to:
a) trap all the errors in my app b) figure out if a hydrate was called recently (200ms?) c) maybe send ourselves the bad hydrate data d) delete the hydrate data and (somehow) restart the app.
Will let you know when I get to it and write some example tests/components for the different crash states.