Skip to content

fix(settings): tolerate blocked localStorage - #26

Merged
daggerok merged 1 commit into
masterfrom
fix/settings-storage-guard
Oct 25, 2026
Merged

daggerok merged 1 commit into
masterfrom
fix/settings-storage-guard

Conversation

@daggerok

Copy link
Copy Markdown
Owner

What

  • Settings useState initializer: localStorage.getItem moved inside the existing try, falls back to DEFAULT_SETTINGS
  • Settings sync effect: localStorage.setItem wrapped in try/catch with a console.warn; the theme class is applied either way

Why

CSV-M1: these were the only two unguarded storage calls (NEEDS_BOOT_RESTORE and the dataset helpers already catch). When storage is blocked, getItem throws SecurityError during the first render and the app shows a blank page. With a full quota, setItem throws inside the effect, so dark or light mode is not applied. Split from the parser fix to keep one concern per PR

Checks

  • bun run build
  • tsc --noEmit --strict --skipLibCheck --jsx react-jsx on src/main.tsx (no errors)
  • Old and new initializer and effect extracted from source and run in Bun with stub storages:
    • blocked storage: old initializer throws SecurityError, new returns defaults; old effect throws, new applies dark
    • full quota on setItem: old effect throws QuotaExceededError, new applies dark
    • saved settings and broken JSON behave as before
  • git diff --check
  • Not run in a browser

The settings initializer called localStorage.getItem outside its try and the settings effect called setItem with no guard. When storage is blocked (privacy settings, sandboxed frame) getItem throws and the app never renders; a full quota made setItem throw inside the effect, skipping the theme class. Both calls are now inside try/catch.
@daggerok
daggerok merged commit 47ff561 into master Oct 25, 2026
3 checks passed
@daggerok
daggerok deleted the fix/settings-storage-guard branch October 25, 2026 03:35

This branch was successfully deployed

2 active deployments
ci — 7aa95292 Deployed Oct 25, 2026 by daggerok via npm-check-updates #95
github-pages — 7aa95292 Deployed Oct 25, 2026 by daggerok via deploy #91
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