Skip to content
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

[question] What's the recommended way to handle render exceptions caused by stale persisted cached data? #501

Open
SimpleCreations opened this issue Sep 21, 2023 · 1 comment

Comments

@SimpleCreations
Copy link

SimpleCreations commented Sep 21, 2023

Let's say I'm using React + Apollo + apollo-cache-persist with a GraphQL backend. Here's the problem:

  1. Let's say the backend released a broken update, returning data that causes the app to crash
  2. The client caches this data
  3. The client uses the data to render UI
  4. The client crashes
  5. On the next launch, the client tries to use the stale data to render UI
  6. The client crashes
  7. Go back to number 5

In this scenario, the users are stuck with a failing web app/crashing mobile app, and the only solution (once a fix to the backend is pushed) for them is to clear their site data/reinstall the app.

What's the recommended way to solve this?
One idea I had so far is to catch render issues with an error boundary and clear the persisted cache in this case.

@nrgbistro
Copy link

nrgbistro commented Oct 16, 2023

you could create a version field that is not cached by configuring a CachePersistor. you can then manually manage caching the version in local storage, and if the version updates, clear the cache (or parts of the cache). alternatively, your proposed solution of clearing the cache manually when you encounter an error on the client seems like your best bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants