Skip to content

Conversation

@mcollina
Copy link
Member

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

@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
@mcollina mcollina force-pushed the localstorage-undefined branch from ebc1299 to c85a48b Compare January 10, 2026 21:22
@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.34%. Comparing base (ce2ec3d) to head (c85a48b).
⚠️ Report is 47 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.34%   -0.20%     
==========================================
  Files         704      704              
  Lines      208734   208762      +28     
  Branches    40271    40260      -11     
==========================================
- Hits       184823   184437     -386     
- Misses      15932    16373     +441     
+ Partials     7979     7952      -27     
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 61 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

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
@mcollina mcollina force-pushed the localstorage-undefined branch from c85a48b to 5b17977 Compare January 11, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants