Skip to content

Commit c7bd97e

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

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

doc/api/cli.md

Lines changed: 20 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,25 @@ 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: v22.7.0
1655+
changes:
1656+
- version: REPLACEME
1657+
pr-url: https://github.com/nodejs/node/pull/12345
1658+
description: Marked as stable.
1659+
-->
1660+
1661+
> Stability: 2 - Stable
1662+
1663+
Enables the use of [`AsyncLocalStorage`][] backed by `AsyncContextFrame` rather
1664+
than the default implementation which relies on async\_hooks. This new model is
1665+
implemented very differently and so could have differences in how context data
1666+
flows within the application. As such, it is presently recommended to be sure
1667+
your application behaviour is unaffected by this change before using it in
1668+
production.
1669+
16661670
### `--no-deprecation`
16671671

16681672
<!-- YAML
@@ -3051,7 +3055,6 @@ one is included in the list below.
30513055
* `--enable-source-maps`
30523056
* `--entry-url`
30533057
* `--experimental-abortcontroller`
3054-
* `--experimental-async-context-frame`
30553058
* `--experimental-default-type`
30563059
* `--experimental-detect-module`
30573060
* `--experimental-eventsource`
@@ -3097,6 +3100,7 @@ one is included in the list below.
30973100
* `--napi-modules`
30983101
* `--network-family-autoselection-attempt-timeout`
30993102
* `--no-addons`
3103+
* `--no-async-context-frame`
31003104
* `--no-deprecation`
31013105
* `--no-experimental-global-navigator`
31023106
* `--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)