From b9bdfc3afa6bd22f98665715c49431da9d7bccbc Mon Sep 17 00:00:00 2001 From: uzlopak Date: Mon, 29 Jan 2024 14:23:34 +0100 Subject: [PATCH] lib: enable WebSocket by default --- doc/api/cli.md | 20 +++++++++----------- doc/api/globals.md | 10 +++++++--- lib/internal/process/pre_execution.js | 2 +- src/node_options.h | 2 +- test/parallel/test-websocket-disabled.js | 7 +++++++ test/parallel/test-websocket.js | 1 - 6 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 test/parallel/test-websocket-disabled.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 840585765e7fa6..91e03bb3515743 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -931,16 +931,6 @@ added: v12.3.0 Enable experimental WebAssembly module support. -### `--experimental-websocket` - - - -Enable experimental [`WebSocket`][] support. - ### `--force-context-aware` + +Use this flag to disable experimental [`WebSocket`][] support. + ### `--no-extra-info-on-fatal-exception` > Stability: 1 - Experimental. -A browser-compatible implementation of [`WebSocket`][]. Enable this API -with the [`--experimental-websocket`][] CLI flag. +A browser-compatible implementation of [`WebSocket`][]. Disable this API +with the [`--no-experimental-websocket`][] CLI flag. ## Class: `WritableStream` @@ -1139,10 +1143,10 @@ A browser-compatible implementation of [`WritableStreamDefaultWriter`][]. [Navigator API]: https://html.spec.whatwg.org/multipage/system-state.html#the-navigator-object [RFC 5646]: https://www.rfc-editor.org/rfc/rfc5646.txt [Web Crypto API]: webcrypto.md -[`--experimental-websocket`]: cli.md#--experimental-websocket [`--no-experimental-global-customevent`]: cli.md#--no-experimental-global-customevent [`--no-experimental-global-navigator`]: cli.md#--no-experimental-global-navigator [`--no-experimental-global-webcrypto`]: cli.md#--no-experimental-global-webcrypto +[`--no-experimental-websocket`]: cli.md#--no-experimental-websocket [`AbortController`]: https://developer.mozilla.org/en-US/docs/Web/API/AbortController [`ByteLengthQueuingStrategy`]: webstreams.md#class-bytelengthqueuingstrategy [`CompressionStream`]: webstreams.md#class-compressionstream diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js index 98533b7828d3ff..49114847d4d1a5 100644 --- a/lib/internal/process/pre_execution.js +++ b/lib/internal/process/pre_execution.js @@ -349,7 +349,7 @@ function setupUndici() { }); } - if (getOptionValue('--experimental-websocket')) { + if (!getOptionValue('--no-experimental-websocket')) { ObjectDefineProperties(globalThis, { WebSocket: lazyInterface('WebSocket'), }); diff --git a/src/node_options.h b/src/node_options.h index 915151b7dc2904..a0b56ebacb436c 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -108,7 +108,7 @@ class EnvironmentOptions : public Options { std::string dns_result_order; bool enable_source_maps = false; bool experimental_fetch = true; - bool experimental_websocket = false; + bool experimental_websocket = true; bool experimental_global_customevent = true; bool experimental_global_navigator = true; bool experimental_global_web_crypto = true; diff --git a/test/parallel/test-websocket-disabled.js b/test/parallel/test-websocket-disabled.js new file mode 100644 index 00000000000000..4d72294367718b --- /dev/null +++ b/test/parallel/test-websocket-disabled.js @@ -0,0 +1,7 @@ +// Flags: --no-experimental-websocket +'use strict'; + +require('../common'); +const assert = require('assert'); + +assert.strictEqual(typeof WebSocket, 'undefined'); diff --git a/test/parallel/test-websocket.js b/test/parallel/test-websocket.js index 2a7069ccf3b739..c595ec12bfb66c 100644 --- a/test/parallel/test-websocket.js +++ b/test/parallel/test-websocket.js @@ -1,4 +1,3 @@ -// Flags: --experimental-websocket 'use strict'; require('../common');