Skip to content

Fixed SharedStorage deprecation warning caused by sodo-search#26416

Merged
mike182uk merged 2 commits intomainfrom
cursor/ONC-1462-sodo-search-shared-storage-warning-247c
Feb 26, 2026
Merged

Fixed SharedStorage deprecation warning caused by sodo-search#26416
mike182uk merged 2 commits intomainfrom
cursor/ONC-1462-sodo-search-shared-storage-warning-247c

Conversation

@mike182uk
Copy link
Copy Markdown
Member

@mike182uk mike182uk commented Feb 16, 2026

ref https://linear.app/ghost/issue/ONC-1462
fixes #26527
fixes #26318

@tryghost/errors pulls in @stdlib/utils-keys which iterates all window properties on load, triggering a Chromium SharedStorage deprecation warning.

The import was only used in ghost/i18n to throw an error for control flow in generateThemeResources. Since ghost/i18n is bundled into sodo-search (and other browser apps), the entire @stdlib chain was included in the client bundle unnecessarily.

Removed the @tryghost/errors import and replaced the throw-to-catch pattern with a flag to indicate when English fallback is needed.

@cursor
Copy link
Copy Markdown

cursor bot commented Feb 16, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 16, 2026

Walkthrough

The ghost/i18n/lib/i18n.js file was modified to refactor locale loading in the generateThemeResources function. The import of @tryghost/errors was removed. The locale loading logic was updated to replace a conditional throw statement with a path existence check combined with a try-catch block. A needsFallback flag was introduced to track when a locale file is missing or fails to load. When this flag is set, the code falls back to the English locale (en.json) unless the current locale is already English. The default export handling for localized JSON was preserved and applied consistently across the fallback logic.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The PR title mentions 'SharedStorage deprecation warning caused by sodo-search', but the actual changes are in ghost/i18n/lib/i18n.js where @tryghost/errors is removed and locale loading logic is refactored. The title does not clearly describe the main technical change (removing @tryghost/errors dependency and refactoring error handling logic). Consider a more descriptive title that highlights the core change, such as 'Remove @tryghost/errors dependency from i18n to fix SharedStorage deprecation warning' or 'Refactor i18n error handling to eliminate @tryghost/errors dependency'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the problem (@tryghost/errors pulling in @stdlib/utils-keys causing deprecation warnings), the impact on client bundles, and the solution implemented.
Linked Issues check ✅ Passed The changes directly address both linked issues (#26527 and #26318) by removing the @tryghost/errors import that caused the deprecated SharedStorage API access from @stdlib/utils-keys.
Out of Scope Changes check ✅ Passed All changes are within scope; the refactoring of locale loading in generateThemeResources is a necessary consequence of removing the error-based control flow pattern.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cursor/ONC-1462-sodo-search-shared-storage-warning-247c

Comment @coderabbitai help to get the list of available commands and usage tips.

@cursor cursor bot force-pushed the cursor/ONC-1462-sodo-search-shared-storage-warning-247c branch from c9f8a7c to cfa5f1a Compare February 16, 2026 15:06
… warning

fixes #26318

The @tryghost/errors package brings in @stdlib/utils-copy which includes
@stdlib/utils-keys. This package has bug detection code that iterates over
all window properties, triggering a deprecation warning when it accesses
window.sharedStorage in Chromium browsers.

Removed the @tryghost/errors import which was only used for control flow
(throwing an error to trigger a catch block). Replaced with a simple flag
to indicate when fallback is needed.

This also reduces the sodo-search bundle size from ~509KB to ~290KB.
@cursor cursor bot force-pushed the cursor/ONC-1462-sodo-search-shared-storage-warning-247c branch from cfa5f1a to 64fcc9e Compare February 26, 2026 12:46
@mike182uk mike182uk changed the title Sodo-search shared storage warning 🐛 Fixed SharedStorage deprecation warning caused by sodo-search Feb 26, 2026
@mike182uk mike182uk marked this pull request as ready for review February 26, 2026 13:40
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ghost/i18n/lib/i18n.js (1)

90-93: ⚠️ Potential issue | 🟡 Minor

Debug message may be misleading when en.json exists but fails to load.

When locale === 'en' and the file exists but fails to load (e.g., invalid JSON), line 68 logs "Error loading theme locale file: en" and then line 91 logs "Theme en.json file not found", which is incorrect—the file was found but couldn't be parsed.

Suggested fix
         } else {
-            debug(`Theme en.json file not found`);
+            debug(`Theme en.json file not found or failed to load`);
             res = {};
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ghost/i18n/lib/i18n.js` around lines 90 - 93, The debug message "Theme
en.json file not found" is misleading when the file exists but fails to parse;
update the logic around loading theme locale files in i18n.js so that you
distinguish a missing file from a load/parse error: introduce or use the
existing file-exists check (reference locale and the debug call) to only log
"Theme {locale}.json file not found" when the file truly doesn't exist, and
otherwise log a parse/load failure with the actual error (include the error in
the debug/error message) and set res = {} as before; ensure the messages
reference locale and reuse the same variables (locale, res, debug) so callers
can see the correct cause.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ghost/i18n/lib/i18n.js`:
- Around line 90-93: The debug message "Theme en.json file not found" is
misleading when the file exists but fails to parse; update the logic around
loading theme locale files in i18n.js so that you distinguish a missing file
from a load/parse error: introduce or use the existing file-exists check
(reference locale and the debug call) to only log "Theme {locale}.json file not
found" when the file truly doesn't exist, and otherwise log a parse/load failure
with the actual error (include the error in the debug/error message) and set res
= {} as before; ensure the messages reference locale and reuse the same
variables (locale, res, debug) so callers can see the correct cause.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 600585b and ee1a6d9.

📒 Files selected for processing (1)
  • ghost/i18n/lib/i18n.js

@mike182uk mike182uk changed the title 🐛 Fixed SharedStorage deprecation warning caused by sodo-search Fixed SharedStorage deprecation warning caused by sodo-search Feb 26, 2026
@mike182uk mike182uk merged commit 884aeba into main Feb 26, 2026
113 of 126 checks passed
@mike182uk mike182uk deleted the cursor/ONC-1462-sodo-search-shared-storage-warning-247c branch February 26, 2026 15:39
mike182uk added a commit that referenced this pull request Mar 4, 2026
ref #26416

Fixed `SharedStorage` deprecation warning
mike182uk added a commit that referenced this pull request Mar 4, 2026
ref #26416

Fixed `SharedStorage` deprecation warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants