Skip to content

useLocalStorage swallows write errors, risking silent data loss #5

Description

@abayomicornelius

In src/hooks/useLocalStorage.ts, the set function calls localStorage.setItem(key, JSON.stringify(s)) with no try/catch, while the initial read is wrapped in one.

In private browsing/quota-exceeded scenarios (used by useContacts and useTheme), this throws uncaught, updates React state without persisting it, and can bubble into ErrorBoundary, wiping the in-progress UI. Wrap the write in a try/catch and surface a toast/error state instead of throwing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions