Skip to content

Commit 3312e4e

Browse files
src: unflag --experimental-webstorage by default
PR-URL: #57666 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Edy Silva <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent eb1e671 commit 3312e4e

File tree

14 files changed

+85
-81
lines changed

14 files changed

+85
-81
lines changed

benchmark/webstorage/getItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function nextLocalStorage() {
1212
}
1313

1414
const options = {
15-
flags: ['--experimental-webstorage', `--localstorage-file=${nextLocalStorage()}`],
15+
flags: [`--localstorage-file=${nextLocalStorage()}`],
1616
};
1717

1818
const bench = common.createBenchmark(main, {

benchmark/webstorage/removeItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function nextLocalStorage() {
1212
}
1313

1414
const options = {
15-
flags: ['--experimental-webstorage', `--localstorage-file=${nextLocalStorage()}`],
15+
flags: [`--localstorage-file=${nextLocalStorage()}`],
1616
};
1717

1818
const bench = common.createBenchmark(main, {

benchmark/webstorage/setItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function nextLocalStorage() {
1212
}
1313

1414
const options = {
15-
flags: ['--experimental-webstorage', `--localstorage-file=${nextLocalStorage()}`],
15+
flags: [`--localstorage-file=${nextLocalStorage()}`],
1616
};
1717

1818
const bench = common.createBenchmark(main, {

doc/api/cli.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,14 +1305,6 @@ changes:
13051305

13061306
Enable experimental WebAssembly System Interface (WASI) support.
13071307

1308-
### `--experimental-webstorage`
1309-
1310-
<!-- YAML
1311-
added: v22.4.0
1312-
-->
1313-
1314-
Enable experimental [`Web Storage`][] support.
1315-
13161308
### `--experimental-worker-inspection`
13171309

13181310
<!-- YAML
@@ -1753,8 +1745,8 @@ added: v22.4.0
17531745

17541746
The file used to store `localStorage` data. If the file does not exist, it is
17551747
created the first time `localStorage` is accessed. The same file may be shared
1756-
between multiple Node.js processes concurrently. This flag is a no-op unless
1757-
Node.js is started with the `--experimental-webstorage` flag.
1748+
between multiple Node.js processes concurrently. This flag is a no-op if
1749+
Node.js is started with the `--no-webstorage` (or `--no-experimental-webstorage`) flag.
17581750

17591751
### `--max-http-header-size=size`
17601752

@@ -1979,6 +1971,14 @@ added: v6.0.0
19791971

19801972
Silence all process warnings (including deprecations).
19811973

1974+
### `--no-webstorage`
1975+
1976+
<!-- YAML
1977+
added: REPLACEME
1978+
-->
1979+
1980+
Disable [`Web Storage`][] support.
1981+
19821982
### `--node-memory-debug`
19831983

19841984
<!-- YAML
@@ -3503,7 +3503,6 @@ one is included in the list below.
35033503
* `--experimental-transform-types`
35043504
* `--experimental-vm-modules`
35053505
* `--experimental-wasi-unstable-preview1`
3506-
* `--experimental-webstorage`
35073506
* `--force-context-aware`
35083507
* `--force-fips`
35093508
* `--force-node-api-uncaught-exceptions-policy`
@@ -3537,11 +3536,13 @@ one is included in the list below.
35373536
* `--no-experimental-sqlite`
35383537
* `--no-experimental-strip-types`
35393538
* `--no-experimental-websocket`
3539+
* `--no-experimental-webstorage`
35403540
* `--no-extra-info-on-fatal-exception`
35413541
* `--no-force-async-hooks-checks`
35423542
* `--no-global-search-paths`
35433543
* `--no-network-family-autoselection`
35443544
* `--no-warnings`
3545+
* `--no-webstorage`
35453546
* `--node-memory-debug`
35463547
* `--openssl-config`
35473548
* `--openssl-legacy-provider`

doc/api/globals.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,11 @@ A browser-compatible implementation of {Headers}.
640640
added: v22.4.0
641641
-->
642642

643-
> Stability: 1.0 - Early development.
644-
645643
A browser-compatible implementation of [`localStorage`][]. Data is stored
646644
unencrypted in the file specified by the [`--localstorage-file`][] CLI flag.
647645
The maximum amount of data that can be stored is 10 MB.
648646
Any modification of this data outside of the Web Storage API is not supported.
649-
Enable this API with the [`--experimental-webstorage`][] CLI flag.
647+
Disable this API with the [`--no-webstorage`][] (or its alias `--no-experimental-webstorage`) CLI flag.
650648
`localStorage` data is not stored per user or per request when used in the context
651649
of a server, it is shared across all users and requests.
652650

@@ -1108,9 +1106,10 @@ added: v22.4.0
11081106
-->
11091107

11101108
> Stability: 1.0 - Early development. Enable this API with the
1111-
> [`--experimental-webstorage`][] CLI flag.
1109+
> \[`--experimental-webstorage`]\[] CLI flag.
11121110
1113-
A browser-compatible implementation of {Storage}.
1111+
A browser-compatible implementation of {Storage}. Disable this API with the
1112+
[`--no-webstorage`][] (or its alias `--no-experimental-webstorage`) CLI flag.
11141113

11151114
## `structuredClone(value[, options])`
11161115

@@ -1321,10 +1320,10 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][].
13211320
[RFC 5646]: https://www.rfc-editor.org/rfc/rfc5646.txt
13221321
[Web Crypto API]: webcrypto.md
13231322
[`--experimental-eventsource`]: cli.md#--experimental-eventsource
1324-
[`--experimental-webstorage`]: cli.md#--experimental-webstorage
13251323
[`--localstorage-file`]: cli.md#--localstorage-filefile
13261324
[`--no-experimental-global-navigator`]: cli.md#--no-experimental-global-navigator
13271325
[`--no-experimental-websocket`]: cli.md#--no-experimental-websocket
1326+
[`--no-webstorage`]: cli.md#--no-webstorage
13281327
[`ByteLengthQueuingStrategy`]: webstreams.md#class-bytelengthqueuingstrategy
13291328
[`CompressionStream`]: webstreams.md#class-compressionstream
13301329
[`CountQueuingStrategy`]: webstreams.md#class-countqueuingstrategy

doc/node-config-schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@
189189
"experimental-websocket": {
190190
"type": "boolean"
191191
},
192-
"experimental-webstorage": {
193-
"type": "boolean"
194-
},
195192
"extra-info-on-fatal-exception": {
196193
"type": "boolean"
197194
},
@@ -597,6 +594,9 @@
597594
"watch-preserve-output": {
598595
"type": "boolean"
599596
},
597+
"webstorage": {
598+
"type": "boolean"
599+
},
600600
"zero-fill-buffers": {
601601
"type": "boolean"
602602
}

doc/node.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ Enable experimental support for the EventSource Web API.
207207
.It Fl -no-experimental-websocket
208208
Disable experimental support for the WebSocket API.
209209
.
210-
.It Fl -experimental-webstorage
211-
Enable experimental support for the Web Storage API.
210+
.It Fl -no-webstorage
211+
Disable webstorage.
212212
.
213213
.It Fl -no-experimental-repl-await
214214
Disable top-level await keyword support in REPL.

lib/internal/process/pre_execution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ function setupQuic() {
365365

366366
function setupWebStorage() {
367367
if (getEmbedderOptions().noBrowserGlobals ||
368-
!getOptionValue('--experimental-webstorage')) {
368+
!getOptionValue('--webstorage')) {
369369
return;
370370
}
371371

lib/internal/webstorage.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
'use strict';
22
const {
33
ObjectDefineProperties,
4+
Proxy,
45
} = primordials;
5-
const { ERR_INVALID_ARG_VALUE } = require('internal/errors').codes;
66
const { getOptionValue } = require('internal/options');
7-
const { emitExperimentalWarning } = require('internal/util');
87
const { kConstructorKey, Storage } = internalBinding('webstorage');
98
const { getValidatedPath } = require('internal/fs/utils');
109
const kInMemoryPath = ':memory:';
1110

12-
emitExperimentalWarning('Web Storage');
13-
1411
module.exports = { Storage };
1512

1613
let lazyLocalStorage;
@@ -27,12 +24,31 @@ ObjectDefineProperties(module.exports, {
2724
const location = getOptionValue('--localstorage-file');
2825

2926
if (location === '') {
30-
throw new ERR_INVALID_ARG_VALUE('--localstorage-file',
31-
location,
32-
'is an invalid localStorage location');
33-
}
27+
let warningEmitted = false;
28+
const handler = {
29+
__proto__: null,
30+
get(target, prop) {
31+
if (!warningEmitted) {
32+
process.emitWarning('`--localstorage-file` was provided without a valid path');
33+
warningEmitted = true;
34+
}
35+
36+
return undefined;
37+
},
38+
set(target, prop, value) {
39+
if (!warningEmitted) {
40+
process.emitWarning('`--localstorage-file` was provided without a valid path');
41+
warningEmitted = true;
42+
}
3443

35-
lazyLocalStorage = new Storage(kConstructorKey, getValidatedPath(location));
44+
return false;
45+
},
46+
};
47+
48+
lazyLocalStorage = new Proxy({}, handler);
49+
} else {
50+
lazyLocalStorage = new Storage(kConstructorKey, getValidatedPath(location));
51+
}
3652
}
3753

3854
return lazyLocalStorage;

src/node_options.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
559559
NoOp{},
560560
#endif
561561
kAllowedInEnvvar);
562-
AddOption("--experimental-webstorage",
563-
"experimental Web Storage API",
564-
&EnvironmentOptions::experimental_webstorage,
565-
kAllowedInEnvvar);
562+
AddOption("--webstorage",
563+
"Web Storage API",
564+
&EnvironmentOptions::webstorage,
565+
kAllowedInEnvvar,
566+
true);
567+
AddAlias("--experimental-webstorage", "--webstorage");
566568
AddOption("--localstorage-file",
567569
"file used to persist localStorage data",
568570
&EnvironmentOptions::localstorage_file,

0 commit comments

Comments
 (0)