fix: show error banner when localStorage data is corrupted#44
Closed
tenacitas-paypa wants to merge 5 commits into
Closed
fix: show error banner when localStorage data is corrupted#44tenacitas-paypa wants to merge 5 commits into
tenacitas-paypa wants to merge 5 commits into
Conversation
✅ Deploy Preview for kid-a ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The app loads blank when localStorage contains corrupted data. React throws during render and nothing is shown to the user.
Solution
Two layers of protection:
1. Soft banner — corrupted localStorage (recoverable)
LocalDataLayerContextnow uses a discriminated-union result type (ok | error | empty) instead of swallowing errors silently. If anykid-a:local:*key contains data that fails parsing or validation, the app renders normally with all local data reset to empty defaults, and shows a dismissible warning banner at the top of the screen:kid-a:local:*keys and dismisses; friends list starts fresh, event progress is unaffected2. Hard crash screen — React render error
AppErrorBoundary(class component wrapping the full tree inmain.tsx) catches any unhandled render exception. Instead of a blank page it shows a full-screen error card with:kid-a:local:*keys and triggerslocation.reload()i18n
New keys added in both
enandes:storage.error.noticestorage.error.clearstorage.error.dismissFiles changed
src/components/AppErrorBoundary.tsxsrc/contexts/LocalDataLayerContext.tsxsrc/main.tsxAppErrorBoundarysrc/i18n/messages.tsenandessrc/styles.css