Skip to content

fix: show error banner when localStorage data is corrupted#44

Closed
tenacitas-paypa wants to merge 5 commits into
mainfrom
fix/localstorage-error-boundary
Closed

fix: show error banner when localStorage data is corrupted#44
tenacitas-paypa wants to merge 5 commits into
mainfrom
fix/localstorage-error-boundary

Conversation

@tenacitas-paypa

Copy link
Copy Markdown
Collaborator

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)

LocalDataLayerContext now uses a discriminated-union result type (ok | error | empty) instead of swallowing errors silently. If any kid-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:

  • Dismiss — hides the banner, app continues working
  • Clear local data — removes all kid-a:local:* keys and dismisses; friends list starts fresh, event progress is unaffected

2. Hard crash screen — React render error

AppErrorBoundary (class component wrapping the full tree in main.tsx) catches any unhandled render exception. Instead of a blank page it shows a full-screen error card with:

  • Human-readable explanation
  • The raw error message for debugging
  • Clear local data and reload button — removes all kid-a:local:* keys and triggers location.reload()

i18n

New keys added in both en and es:

  • storage.error.notice
  • storage.error.clear
  • storage.error.dismiss

Files changed

File Change
src/components/AppErrorBoundary.tsx New — React error boundary with crash screen
src/contexts/LocalDataLayerContext.tsx Soft banner on corrupted data; typed read results
src/main.tsx Wrap tree in AppErrorBoundary
src/i18n/messages.ts 3 new keys in en and es
src/styles.css Styles for banner and crash screen

@netlify

netlify Bot commented Jun 26, 2026

Copy link
Copy Markdown

Deploy Preview for kid-a ready!

Name Link
🔨 Latest commit 3aba2f4
🔍 Latest deploy log https://app.netlify.com/projects/kid-a/deploys/6a3e3e4305d3de000889c35f
😎 Deploy Preview https://deploy-preview-44--kid-a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@tenacitas-paypa
tenacitas-paypa deleted the fix/localstorage-error-boundary branch June 26, 2026 09:02
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

Successfully merging this pull request may close these issues.

1 participant