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 合併指標
 (平均合併 16天 20小時) (30 天內合併 1 個 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

貢獻者指南