UTDNebula/utd-trends

Surround localStorage gets with a try-catch

开放

#634 创建于 2026年5月30日

 (0 条评论) (0 个反应) (0 位负责人)TypeScript (35 个派生)auto 404
Good First IssueType: Internal

仓库指标

星标
 (28 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Issue

Sentry Issue: TRENDS-5X

In src/modules/usePersistantState.tsx there is no try-catch around the localStorage call:

function setFromStorage() {
      const value = localStorage.getItem(key);
      if (!value) {
        if (useDefaultValue) {
          internalSetState(defaultValueRef.current);
        }
        return;

leading to a:

SecurityError: The operation is insecure.
  at t (src/modules/usePersistantState.tsx:15:21)
  at <anonymous> (src/modules/usePersistantState.tsx:31:5)
...
(45 additional frame(s) were not displayed)

  • check if there are other localStorage calls without a try-catch in our codebase
  • ensure errors are handled

贡献者指南