lib: make ALS default to AsyncContextFrame

PR-URL: https://github.com/nodejs/node/pull/55552
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
Stephen Belanger authored and GitHub committed 2024-11-02 15:14:28 +00:00
1 parent c0db893f04
commit 51ae57673d
4 files changed
+20 -21

No files matched your search

+14 -16
View File
@@ -930,21 +930,6 @@ and `"` are usable.
It is possible to run code containing inline types by passing
[`--experimental-strip-types`][].
### `--experimental-async-context-frame`
<!-- YAML
added: v22.7.0
-->
> Stability: 1 - Experimental
Enables the use of [`AsyncLocalStorage`][] backed by `AsyncContextFrame` rather
than the default implementation which relies on async\_hooks. This new model is
implemented very differently and so could have differences in how context data
flows within the application. As such, it is presently recommended to be sure
your application behaviour is unaffected by this change before using it in
production.
### `--experimental-default-type=type`
<!-- YAML
@@ -1663,6 +1648,19 @@ Disable the `node-addons` exports condition as well as disable loading
native addons. When `--no-addons` is specified, calling `process.dlopen` or
requiring a native C++ addon will fail and throw an exception.
### `--no-async-context-frame`
<!-- YAML
added: REPLACEME
-->
> Stability: 2 - Stable
Disables the use of [`AsyncLocalStorage`][] backed by `AsyncContextFrame` and
uses the prior implementation which relied on async\_hooks. The previous model
is retained for compatibility with Electron and for cases where the context
flow may differ. However, if a difference in flow is found please report it.
### `--no-deprecation`
<!-- YAML
@@ -3051,7 +3049,6 @@ one is included in the list below.
* `--enable-source-maps`
* `--entry-url`
* `--experimental-abortcontroller`
* `--experimental-async-context-frame`
* `--experimental-default-type`
* `--experimental-detect-module`
* `--experimental-eventsource`
@@ -3097,6 +3094,7 @@ one is included in the list below.
* `--napi-modules`
* `--network-family-autoselection-attempt-timeout`
* `--no-addons`
* `--no-async-context-frame`
* `--no-deprecation`
* `--no-experimental-global-navigator`
* `--no-experimental-repl-await`
+1 -1
View File
@@ -38,7 +38,7 @@ class ActiveAsyncContextFrame extends Map {
function checkEnabled() {
const enabled = require('internal/options')
.getOptionValue('--experimental-async-context-frame');
.getOptionValue('--async-context-frame');
// If enabled, swap to active prototype so we don't need to check status
// on every interaction with the async context frame.
+3 -2
View File
@@ -500,10 +500,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption(
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
AddOption("--expose-gc", "expose gc extension", V8Option{}, kAllowedInEnvvar);
AddOption("--experimental-async-context-frame",
AddOption("--async-context-frame",
"Improve AsyncLocalStorage performance with AsyncContextFrame",
&EnvironmentOptions::async_context_frame,
kAllowedInEnvvar);
kAllowedInEnvvar,
true);
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
AddOption("--frozen-intrinsics",
"experimental frozen intrinsics support",
@@ -41,7 +41,7 @@ const tests = testSets.reduce((m, v) => {
return m;
}, []);
describe('AsyncContextFrame', {
describe('without AsyncContextFrame', {
// TODO(qard): I think high concurrency causes memory problems on Windows
// concurrency: tests.length
}, () => {
@@ -49,7 +49,7 @@ describe('AsyncContextFrame', {
it(test, async () => {
const proc = spawn(python, [
testRunner,
'--node-args=--experimental-async-context-frame',
'--node-args=--no-async-context-frame',
test,
], {
stdio: ['ignore', 'ignore', 'inherit'],