Skip to content

fix(vidstack): guard localStorage access when unavailable - #1857

Open
cycsmail wants to merge 1 commit into
vidstack:mainfrom
cycsmail:fix-localstorage-unavailable-1444
Open

fix(vidstack): guard localStorage access when unavailable#1857
cycsmail wants to merge 1 commit into
vidstack:mainfrom
cycsmail:fix-localstorage-unavailable-1444

Conversation

@cycsmail

@cycsmail cycsmail commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • add a LocalStorage wrapper in utils/storage.ts that guards getItem/setItem/removeItem in a try/catch
  • route the player's storage reads/writes (media storage, font vars/options, default-layout menu checkbox) through it

Why

Some mobile WebViews expose localStorage as null (or throw on access when storage is disabled), so the direct localStorage.getItem(...) calls throw a TypeError and crash the player on init. The wrapper returns null / no-ops in that case instead of throwing.

pnpm --filter vidstack test passes (64 tests), including a new media-storage.test.ts that stubs localStorage as null and asserts LocalMediaStorage doesn't throw. typecheck/oxfmt not run in this pass.

Fixes #1444.

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.

localStorage not always available, causing TypeErrors

1 participant