Repository navigation
fix(storage): stop crashing when browser storage is full or blocked - #283
Merged
Merged
Conversation
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>
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
Production error on Logora Debate:
QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value of 'TextEditor:content_Argument75046' exceeded the quotaThe text editor autosaves drafts through
@rooks/use-localstorage-state, which callslocalStorage.setIteminside auseEffectwithout 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-statehas 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: directlocalStorageaccess in try/catch. Same key and data format, so existing drafts still restore.useSessionStorageStatehook (@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.@rooks/use-localstorage-stateand@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
storagelistener; no component relied on it.Tests
TextEditor.test.jsx: editor still works whensetItemthrowsQuotaExceededError(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 checkcan'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