Skip to content

fix(hooks): catch storage write/remove errors gracefully in useLocalStorage (#5) - #87

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/use-local-storage-write-error
Open

fix(hooks): catch storage write/remove errors gracefully in useLocalStorage (#5)#87
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/use-local-storage-write-error

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Addresses #5: .

Changes

  • Wrapped in a inside the setter so that storage exceptions (e.g. in private browsing or storage quota overflow) do not throw uncaught errors or break component tree execution / .
  • Wrapped in a for defensive handling against or disabled storage policies.
  • Stabilized COREPACK_HOME='/usr/local/share/corepack'
    HOME='/home/node'
    HOSTNAME='instance-20220302-0334'
    IFS='
    '
    NODE_ENV='production'
    NODE_VERSION='24.16.0'
    OPENCLAW_CLI='1'
    OPENCLAW_GATEWAY_PORT='18789'
    OPENCLAW_PATH_BOOTSTRAPPED='1'
    OPENCLAW_SHELL='exec'
    OPTIND='1'
    PATH='/home/node/.cargo/bin:/home/node/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin:/home/node/.local/share/pnpm'
    PLAYWRIGHT_BROWSERS_PATH='/home/node/.cache/ms-playwright'
    PPID='7'
    PS1='$ '
    PS2='> '
    PS4='+ '
    PWD='/home/node/.openclaw/workspace'
    YARN_VERSION='1.22.22' and callbacks using .
  • Maintained in-memory state functionality when storage writes fail so session state remains operational.
  • Added comprehensive test suite in verifying read fallback, successful updates, handling without throwing, and key removal.

Closes #5.

…torage (StellarSend#5)

- Wrap localStorage.setItem and localStorage.removeItem in try/catch blocks
- Log warning to console on storage failure while keeping in-memory state functional
- Use useCallback for stable set/remove handlers across renders
- Add comprehensive unit tests covering read fallback, set, quota exceeded, and removal
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.

useLocalStorage swallows write errors, risking silent data loss

1 participant