fix(ThemeContext): Guard localStorage access to prevent ReferenceError - #4076
fix(ThemeContext): Guard localStorage access to prevent ReferenceError#4076sentry[bot] wants to merge 1 commit into
Conversation
Bundle ReportChanges will increase total bundle size by 185 bytes (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: gazebo-production-systemAssets Changed:
Files in
view changes for bundle: gazebo-production-esmAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4076 +/- ##
==========================================
- Coverage 98.76% 98.76% -0.01%
==========================================
Files 822 822
Lines 15092 15096 +4
Branches 4351 4364 +13
==========================================
+ Hits 14906 14909 +3
- Misses 179 180 +1
Partials 7 7
Continue to review full report in Codecov by Harness.
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #4076 +/- ##
==========================================
- Coverage 98.76% 98.76% -0.01%
==========================================
Files 822 822
Lines 15092 15096 +4
Branches 4351 4356 +5
==========================================
+ Hits 14906 14909 +3
- Misses 179 180 +1
Partials 7 7
Continue to review full report in Codecov by Sentry.
|
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
@@ Coverage Diff @@
## main #4076 +/- ##
==========================================
- Coverage 98.76% 98.76% -0.01%
==========================================
Files 822 822
Lines 15092 15096 +4
Branches 4359 4356 -3
==========================================
+ Hits 14906 14909 +3
- Misses 179 180 +1
Partials 7 7
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
✅ Deploy preview for gazebo ready!Previews expire after 1 month automatically.
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #4076 +/- ##
==========================================
- Coverage 98.76% 98.76% -0.01%
==========================================
Files 822 822
Lines 15092 15096 +4
Branches 4359 4364 +5
==========================================
+ Hits 14906 14909 +3
- Misses 179 180 +1
Partials 7 7
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Description
This PR addresses GAZEBO-17KQ, a
ReferenceError: Can't find variable: localStoragethat occurred in environments wherelocalStorageis not available (e.g., Apple Mail webviews).Code Example
Notable Changes
The
ThemeContextProviderinsrc/shared/ThemeContext/ThemeContext.tsxwas attempting to accesslocalStorage.getItemandlocalStorage.setItemdirectly. This led to a crash whenlocalStoragewas undefined.The fix involves adding
typeof localStorage !== 'undefined'checks around alllocalStorageaccesses withinThemeContext.tsxto ensure these operations are only performed whenlocalStorageis present, thus preventing theReferenceError.Screenshots
Link to Sample Entry
GAZEBO-17KQ
Legal Boilerplate
Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.
Fixes GAZEBO-17KQ