Skip to content

Commit a61b8d7

Browse files
committed
lib: make ALS default to AsyncContextFrame
1 parent c63255b commit a61b8d7

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

doc/api/cli.md

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -930,21 +930,6 @@ and `"` are usable.
930930
It is possible to run code containing inline types by passing
931931
[`--experimental-strip-types`][].
932932

933-
### `--experimental-async-context-frame`
934-
935-
<!-- YAML
936-
added: v22.7.0
937-
-->
938-
939-
> Stability: 1 - Experimental
940-
941-
Enables the use of [`AsyncLocalStorage`][] backed by `AsyncContextFrame` rather
942-
than the default implementation which relies on async\_hooks. This new model is
943-
implemented very differently and so could have differences in how context data
944-
flows within the application. As such, it is presently recommended to be sure
945-
your application behaviour is unaffected by this change before using it in
946-
production.
947-
948933
### `--experimental-default-type=type`
949934

950935
<!-- YAML
@@ -1663,6 +1648,19 @@ Disable the `node-addons` exports condition as well as disable loading
16631648
native addons. When `--no-addons` is specified, calling `process.dlopen` or
16641649
requiring a native C++ addon will fail and throw an exception.
16651650

1651+
### `--no-async-context-frame`
1652+
1653+
<!-- YAML
1654+
added: REPLACEME
1655+
-->
1656+
1657+
> Stability: 2 - Stable
1658+
1659+
Disables the use of [`AsyncLocalStorage`][] backed by `AsyncContextFrame` and
1660+
uses the prior implementation which relied on async\_hooks. The previous model
1661+
is retained for compatibility with Electron and for cases where the context
1662+
flow may differ. However, if a difference in flow is found please report it.
1663+
16661664
### `--no-deprecation`
16671665

16681666
<!-- YAML
@@ -3051,7 +3049,6 @@ one is included in the list below.
30513049
* `--enable-source-maps`
30523050
* `--entry-url`
30533051
* `--experimental-abortcontroller`
3054-
* `--experimental-async-context-frame`
30553052
* `--experimental-default-type`
30563053
* `--experimental-detect-module`
30573054
* `--experimental-eventsource`
@@ -3097,6 +3094,7 @@ one is included in the list below.
30973094
* `--napi-modules`
30983095
* `--network-family-autoselection-attempt-timeout`
30993096
* `--no-addons`
3097+
* `--no-async-context-frame`
31003098
* `--no-deprecation`
31013099
* `--no-experimental-global-navigator`
31023100
* `--no-experimental-repl-await`

lib/internal/async_context_frame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ActiveAsyncContextFrame extends Map {
3838

3939
function checkEnabled() {
4040
const enabled = require('internal/options')
41-
.getOptionValue('--experimental-async-context-frame');
41+
.getOptionValue('--async-context-frame');
4242

4343
// If enabled, swap to active prototype so we don't need to check status
4444
// on every interaction with the async context frame.

src/node_options.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
500500
AddOption(
501501
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
502502
AddOption("--expose-gc", "expose gc extension", V8Option{}, kAllowedInEnvvar);
503-
AddOption("--experimental-async-context-frame",
503+
AddOption("--async-context-frame",
504504
"Improve AsyncLocalStorage performance with AsyncContextFrame",
505505
&EnvironmentOptions::async_context_frame,
506-
kAllowedInEnvvar);
506+
kAllowedInEnvvar,
507+
true);
507508
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
508509
AddOption("--frozen-intrinsics",
509510
"experimental frozen intrinsics support",

test/parallel/test-async-context-frame.mjs renamed to test/parallel/test-without-async-context-frame.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ const tests = testSets.reduce((m, v) => {
4141
return m;
4242
}, []);
4343

44-
describe('AsyncContextFrame', {
44+
describe('without AsyncContextFrame', {
4545
// TODO(qard): I think high concurrency causes memory problems on Windows
4646
// concurrency: tests.length
4747
}, () => {
4848
for (const test of tests) {
4949
it(test, async () => {
5050
const proc = spawn(python, [
5151
testRunner,
52-
'--node-args=--experimental-async-context-frame',
52+
'--node-args=--no-async-context-frame',
5353
test,
5454
], {
5555
stdio: ['ignore', 'ignore', 'inherit'],

0 commit comments

Comments
 (0)