node icon indicating copy to clipboard operation
node copied to clipboard

src,lib,test: unflag --experimental-webstorage by default

Open danielmbrasil opened this issue 9 months ago β€’ 14 comments

Resolves #57658

danielmbrasil avatar Mar 28 '25 17:03 danielmbrasil

Review requested:

  • [ ] @nodejs/config

nodejs-github-bot avatar Mar 28 '25 17:03 nodejs-github-bot

To fix the failing test, I would change the error being throw in lib/internal/webstorage.js in a warning, and have localStorage be undefined in that case.

@cjihrig wdyt?

mcollina avatar Mar 28 '25 18:03 mcollina

I would be OK with that behavior. However, the global checking logic in test/common/index.js would probably need to be updated. Otherwise, the new warning will probably be printed for every test that doesn't use localStorage.

cjihrig avatar Mar 28 '25 18:03 cjihrig

I just pushed the suggested changes, and the tests are now passing. @cjihrig, could you please review whether the changes in test/common/index.js make sense?

danielmbrasil avatar Mar 28 '25 20:03 danielmbrasil

Without running the code, it doesn't look correct to me:

globalThis[val] === undefined

By the time we find out that the value is undefined, the warning will have already been emitted, right?

cjihrig avatar Mar 28 '25 20:03 cjihrig

By the time we find out that the value is undefined, the warning will have already been emitted, right?

Yeah, that's right. I'll take a look on how to avoid the warning to be emitted in those cases.

danielmbrasil avatar Mar 28 '25 20:03 danielmbrasil

@cjihrig Could you take a look now and see if this is closer to what you were expecting? I added a new check to test/common/index.js that overrides the localStorage getter with an empty object. This prevents the warning from being emitted, and the tests are passing locally.

danielmbrasil avatar Apr 02 '25 17:04 danielmbrasil

Moving this as ready for review. I think we should possibly also update doc/api/cli.md and doc/api/globals.md, but I'm not sure how to update those docs for now.

danielmbrasil avatar Apr 04 '25 18:04 danielmbrasil

Codecov Report

:x: Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 88.28%. Comparing base (73b5022) to head (890a794). :warning: Report is 116 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/webstorage.js 80.00% 5 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57666      +/-   ##
==========================================
+ Coverage   88.26%   88.28%   +0.02%     
==========================================
  Files         701      701              
  Lines      206644   206676      +32     
  Branches    39737    39738       +1     
==========================================
+ Hits       182386   182472      +86     
+ Misses      16279    16237      -42     
+ Partials     7979     7967      -12     
Files with missing lines Coverage Ξ”
lib/internal/process/pre_execution.js 97.15% <100.00%> (-0.28%) :arrow_down:
src/node_options.cc 77.89% <100.00%> (+0.02%) :arrow_up:
src/node_options.h 97.89% <100.00%> (ΓΈ)
lib/internal/webstorage.js 91.30% <80.00%> (-8.70%) :arrow_down:

... and 41 files with indirect coverage changes

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

codecov[bot] avatar Apr 04 '25 19:04 codecov[bot]

A few tests needs fixing but this is good progress!

mcollina avatar Apr 07 '25 13:04 mcollina

This PR has some conflicts

geeksilva97 avatar May 26 '25 13:05 geeksilva97

CI: https://ci.nodejs.org/job/node-test-pull-request/67184/

nodejs-github-bot avatar May 29 '25 17:05 nodejs-github-bot

Specifically we have --no-experimental-webstorage, which should either be dropped or be aliased to --no-webstorage. Wdyt?

Yes, in a PR to stabilize, I'd rename --no-experimental-webstorage to --no-webstorage for a bit before dropping it. That said, I'd also be fine with removing it completely, but I can't remember what all of the project policies are around that anymore.

cjihrig avatar Jun 09 '25 21:06 cjihrig

@mcollina I've marked it as stable in the docs.

danielmbrasil avatar Jun 10 '25 12:06 danielmbrasil

Hi @danielmbrasil and maintainers! πŸ‘‹

I was working on this same issue independently and created a duplicate PR (#58736) which I've now closed in favor of this one. I'd love to help get this merged by addressing the remaining blockers.

Looking at the current issues, I see two main blockers:

1. Experimental Warning Inconsistency

The docs mark it as "stable" but the code still emits experimental warnings. I suggest we fully stabilize since:

  • @cjihrig and @mcollina both agreed to stabilize
  • Web Storage API is incredibly stable in browsers
  • It's been in Node.js for a while now

Proposed fix: Remove emitExperimentalWarning('Web Storage') from lib/internal/webstorage.js

2. Flag Aliases

Need to add --webstorage/--no-webstorage aliases while keeping backward compatibility.

Proposed implementation:

// In src/node_options.cc
AddOption("--webstorage",
          "Web Storage API (default: true)",
          &EnvironmentOptions::experimental_webstorage,
          kAllowedInEnvvar,
          true);
AddOption("--experimental-webstorage", 
          "alias for --webstorage (deprecated)",
          &EnvironmentOptions::experimental_webstorage,
          kAllowedInEnvvar,
          true); 

Would you like me to prepare specific code suggestions for these fixes? Happy to collaborate! 🀝

@mcollina @cjihrig - does this approach align with your vision for stabilizing webstorage?

emicovi avatar Jun 17 '25 07:06 emicovi

cc @nodejs/tsc we need another approval

mcollina avatar Jun 17 '25 14:06 mcollina

CI: https://ci.nodejs.org/job/node-test-pull-request/67501/

nodejs-github-bot avatar Jun 17 '25 14:06 nodejs-github-bot

cc @nodejs/tsc we need another approval

TSC specifically ?

geeksilva97 avatar Jun 17 '25 14:06 geeksilva97

It's semver-major.

mcollina avatar Jun 17 '25 14:06 mcollina

It's semver-major.

got it. ty

geeksilva97 avatar Jun 17 '25 14:06 geeksilva97

CI: https://ci.nodejs.org/job/node-test-pull-request/67502/

nodejs-github-bot avatar Jun 17 '25 16:06 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/67592/

nodejs-github-bot avatar Jun 21 '25 16:06 nodejs-github-bot

CI is now failing

mcollina avatar Jul 09 '25 10:07 mcollina

Failed to start CI
   ⚠  Commits were pushed since the last approving review:
   ⚠  - src: unflag --experimental-webstorage by default
   ⚠  - lib: return undefined for localStorage when location is invalid
   ⚠  - test: remove --experimental-webstorage flag from tests
   ⚠  - lib: use process.emitWarning instead of emitWarning
   ⚠  - benchmark: remove --experimental-webstorage
   ⚠  - lib: remove unused import
   ⚠  - lib: reword warning for --localstorage-file to fix no-regex-spaces lint
   ⚠  - test: add localStorage and sessionStorage to globalThis test
   ⚠  - doc: add --no-experimental-webstorage docs
   ⚠  - test: improve localStorage mock to fix failing test case
   ⚠  - doc: fix ordering in doc/api/globals.md
   ⚠  - test: set getter name to 'get localStorage' in mock for compatibility
   ⚠  - test: use Flags comment option to set a localstorage file
   ⚠  - test: include test for new --no-experimental-webstorage flag
   ⚠  - test: add --localstorage-file flag to --no-experimental-webstorage test
   ⚠  - test: fix linter issue
   ⚠  - lib: add experimental warning back in
   ⚠  - doc: mark localStorage as stable
   ⚠  - src: add --webstorage alias
   ⚠  - lib: remove experimental warning
   ⚠  - doc: add --webstorage alias to docs
   ⚠  - test: fix tests
   ⚠  - doc: fix lint error
   ⚠  - lib: delay localstorage warning with proxy
   ⚠  - test: remove --locastorage-file flag from tests
   ⚠  - src,lib: rename experimental_experimental option
   ⚠  - doc: update docs
   ⚠  - lib: fix linter errors
   ⚠  - test: remove useless change
   ⚠  - doc: update node-config-schema.json
   ⚠  - doc: fix markdown error
   ⚠  - doc: fix failing tests
   ✘  Refusing to run CI on potentially unsafe PR
https://github.com/nodejs/node/actions/runs/16681856504

github-actions[bot] avatar Aug 01 '25 18:08 github-actions[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/68359/

nodejs-github-bot avatar Aug 01 '25 18:08 nodejs-github-bot

@jasnell PTAL

mcollina avatar Aug 04 '25 07:08 mcollina

CI: https://ci.nodejs.org/job/node-test-pull-request/68395/

nodejs-github-bot avatar Aug 04 '25 07:08 nodejs-github-bot

Hi @jasnell could you re-review?

geeksilva97 avatar Aug 05 '25 17:08 geeksilva97

CI: https://ci.nodejs.org/job/node-test-pull-request/68471/

nodejs-github-bot avatar Aug 07 '25 14:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/68480/

nodejs-github-bot avatar Aug 07 '25 17:08 nodejs-github-bot