Summary
Preferences load and save touch localStorage outside any guard, so a browser where storage is blocked (sandboxed iframe, some private modes, storage disabled) throws during module init and takes the whole app down before React mounts.
Details
src/stores/preferencesStore.ts:137:
const storedData = localStorage.getItem(STORAGE_KEY);
This runs at module-evaluation time. The try at line 141 wraps only JSON.parse, not the getItem. If getItem throws, it propagates out of loadPreferences() during import.
The persist subscriber has the same exposure on write, src/stores/preferencesStore.ts:183-185:
usePreferences.subscribe((state) => {
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
});
Because this throws inside a Zustand listener, a quota-exceeded on write surfaces as the failure of whatever unrelated set() call triggered it.
Contrast src/hooks/useChannelHistory.tsx:147 and :177, which wrap both the read and the write.
Fix direction
Wrap both getItem and setItem in try/catch and degrade to in-memory defaults when storage is unavailable.
Verification
Read src/stores/preferencesStore.ts end to end.
Summary
Preferences load and save touch
localStorageoutside any guard, so a browser where storage is blocked (sandboxed iframe, some private modes, storage disabled) throws during module init and takes the whole app down before React mounts.Details
src/stores/preferencesStore.ts:137:This runs at module-evaluation time. The
tryat line 141 wraps onlyJSON.parse, not thegetItem. IfgetItemthrows, it propagates out ofloadPreferences()during import.The persist subscriber has the same exposure on write,
src/stores/preferencesStore.ts:183-185:Because this throws inside a Zustand listener, a quota-exceeded on write surfaces as the failure of whatever unrelated
set()call triggered it.Contrast
src/hooks/useChannelHistory.tsx:147and:177, which wrap both the read and the write.Fix direction
Wrap both
getItemandsetItemin try/catch and degrade to in-memory defaults when storage is unavailable.Verification
Read
src/stores/preferencesStore.tsend to end.