Skip to content

inspector: report an error when DOM storage is unavailable - #65973

Open
zeexzeex wants to merge 1 commit into
nodejs:mainfrom
zeexzeex:inspector/65895-dom-storage-unavailable
Open

zeexzeex wants to merge 1 commit into
nodejs:mainfrom
zeexzeex:inspector/65895-dom-storage-unavailable

Conversation

@zeexzeex

Copy link
Copy Markdown

getDOMStorageItems() falls back to reading the live Storage object when its cached map is empty. When getWebStorage() cannot produce one, the fallback was skipped and the command still answered with Success and an empty entries array. A frontend could not tell an empty store from a store that cannot be read.

getWebStorage() returns nothing whenever globalThis.localStorage is missing or is not an object, which is the case for any process started without --localstorage-file.

This returns a ServerError in that case, matching how the other failure paths in the same command report problems.

Note that this changes what a frontend sees for a process started without --localstorage-file, which is the common case. sessionStorage is unaffected: it is always backed by an in-memory store, so it stays readable and keeps answering with an empty list.

Fixes: #65895

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/inspector

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Node.js, and thank you for your first contribution!

Before review, please take a moment to read:

Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal.

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.22%. Comparing base (bd9d82d) to head (a1f59f6).
⚠️ Report is 73 commits behind head on main.

Files with missing lines Patch % Lines
src/inspector/storage_agent.cc 54.54% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65973      +/-   ##
==========================================
+ Coverage   90.16%   90.22%   +0.05%     
==========================================
  Files         771      785      +14     
  Lines      265485   269356    +3871     
  Branches    50466    51519    +1053     
==========================================
+ Hits       239381   243021    +3640     
+ Misses      17043    16857     -186     
- Partials     9061     9478     +417     
Files with missing lines Coverage Δ
src/inspector/dom_storage_agent.cc 88.26% <100.00%> (+1.94%) ⬆️
src/inspector/storage_agent.cc 79.16% <54.54%> (-20.84%) ⬇️

... and 128 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zeexzeex
zeexzeex force-pushed the inspector/65895-dom-storage-unavailable branch from be26547 to 9f5f91f Compare September 11, 2026 07:23
@zeexzeex

Copy link
Copy Markdown
Author

The test I added called Storage.getStorageKey without --localstorage-file, which aborted the process on Linux CI: localstorage_file is empty there and std::filesystem::absolute() throws on an empty path under libstdc++, while libc++ returns the current directory. That is why it passed locally on macOS.

This adds a fix for that in storage_agent.cc, so the PR now touches two files it did not before. Flagging it since you have already approved.

MikeMcC399

This comment was marked as resolved.

getDOMStorageItems() falls back to reading the live Storage object when
its cached map is empty. When getWebStorage() cannot produce one, the
fallback was skipped and the command still answered with Success and an
empty entries array, so a frontend could not tell an empty store from a
store that cannot be read.

getWebStorage() returns nothing whenever globalThis.localStorage is
missing or is not an object, which is the case for any process started
without --localstorage-file.

Return a ServerError in that case, matching how the other failure paths
in the same command report problems.

Reading the storage key in that same configuration aborted the process:
localstorage_file is an empty string, and std::filesystem::absolute()
throws on it under libstdc++ while returning the current directory
under libc++. Node builds without exceptions, so the throw terminated
the process. Use the error_code overloads of absolute() and
weakly_canonical() and report the failure through DispatchResponse.

Fixes: nodejs#65895
Signed-off-by: Avocado <ujubongbong@gmail.com>
@zeexzeex
zeexzeex force-pushed the inspector/65895-dom-storage-unavailable branch from 9f5f91f to a1f59f6 Compare September 14, 2026 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inspector: getDOMStorageItems reports unavailable storage as empty

4 participants