Skip to content

fix(storage): stop crashing when browser storage is full or blocked - #283

Merged
Mboulgour merged 1 commit into
masterfrom
fix/storage-quota-crash
Sep 29, 2026
Merged

Mboulgour merged 1 commit into
masterfrom
fix/storage-quota-crash

Conversation

@Mboulgour

Copy link
Copy Markdown
Collaborator

Problem

Production error on Logora Debate:
QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value of 'TextEditor:content_Argument75046' exceeded the quota

The text editor autosaves drafts through @rooks/use-localstorage-state, which calls localStorage.setItem inside a useEffect without error handling. localStorage quota is per origin, so on embedded debates it's shared with the host site. Once it's full, the throw crashes the argument input. @rooks/use-sessionstorage-state has the same problem, used in 7 components (ArgumentInput, VoteBox, SuggestionInput, IntlProvider, SignupForm, SSOForm, SocialAuthForm). It can also throw on read (SecurityError when storage is blocked).

Fix

  • AutoSavePlugin / ResetPlugin: direct localStorage access in try/catch. Same key and data format, so existing drafts still restore.
  • New useSessionStorageState hook (@logora/debate/hooks/use_session_storage_state), a drop-in for the rooks hook (same [value, set, remove] API, same write-on-change behavior), with every storage call guarded. All 7 components now use it.
  • Removed @rooks/use-localstorage-state and @rooks/use-sessionstorage-state.

Behavior change: if storage is full or blocked, drafts and saved state just aren't persisted and the UI keeps working. Dropped the rooks cross-tab storage listener; no component relied on it.

Tests

  • TextEditor.test.jsx: editor still works when setItem throws QuotaExceededError (fails on the old code); draft round trip (save → remount → restored).
  • useSessionStorageState.test.jsx: read/save/remove, and no throw when storage fails.
  • vitest run: 644 passed.

Note: biome check can't run on master (biome.json is on the 1.9.4 schema, installed Biome is 2.5.0). This is pre-existing and not touched here.

Follow-up in LogoraDebate: ProposalInput and ArgumentList.

🤖 Generated with Claude Code

Text editor drafts and session-stored input state called setItem/getItem
unguarded (via @rooks storage hooks), so a QuotaExceededError or SecurityError
crashed the input. Replace both rooks hooks with guarded access: a
useSessionStorageState drop-in hook and direct try/catch in the text editor
autosave/reset plugins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mboulgour
Mboulgour merged commit a8769e4 into master Sep 29, 2026
2 checks passed
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