Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lib: return undefined for localStorage without file #61333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mcollina wants to merge 1 commit into nodejs:main
base: main
Choose a base branch
Loading
from mcollina:localstorage-undefined

Conversation

@mcollina
Copy link
Member

@mcollina mcollina commented Jan 10, 2026

Make localStorage return undefined and emit a warning when
--localstorage-file is not provided. Mark the property as
non-enumerable to avoid breaking {...globalThis}.

Fixes: #60303

bricss reacted with rocket emoji
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Jan 10, 2026
Copy link

codecov bot commented Jan 10, 2026
edited
Loading

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.51%. Comparing base (ce2ec3d) to head (b044f0a).
⚠️ Report is 51 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/process/pre_execution.js 94.73% 1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@
## main #61333 +/- ##
==========================================
- Coverage 88.54% 88.51% -0.04% 
==========================================
 Files 704 704 
 Lines 208734 208762 +28 
 Branches 40271 40272 +1 
==========================================
- Hits 184823 184778 -45 
- Misses 15932 15977 +45 
- Partials 7979 8007 +28 
Files with missing lines Coverage Δ
lib/internal/webstorage.js 100.00% <100.00%> (ø)
lib/internal/process/pre_execution.js 98.43% <94.73%> (-0.10%) ⬇️

... and 35 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.

defineReplaceableLazyAttribute(globalThis, 'internal/webstorage', [
'localStorage', 'sessionStorage',
Copy link
Member

@avivkeller avivkeller Jan 11, 2026

Choose a reason for hiding this comment

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

Couldn't you keep this call the same, and do something like

ObjectDefineProperty(globalThis, 'localStorage', {
 enumerable: ...
});

Instead of re-writing the whole implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm sorry, but I don't understand what you are asking.

Make localStorage return undefined and emit a warning when
--localstorage-file is not provided. Mark the property as
non-enumerable to avoid breaking {...globalThis}.
Fixes: nodejs#60303 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@avivkeller avivkeller avivkeller left review comments

@anonrig anonrig anonrig approved these changes

@cjihrig cjihrig cjihrig approved these changes

Assignees

No one assigned

Labels

needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

localStorage's behaviour when no or invalid --localstorage-file provided

AltStyle によって変換されたページ (->オリジナル) /