Skip to content

Commit ed9abb7

Browse files
Qardmcollina
authored andcommitted
lib: make ALS default to AsyncContextFrame
PR-URL: nodejs#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>
1 parent c7330e6 commit ed9abb7

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

doc/api/cli.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,19 @@ Disable the `node-addons` exports condition as well as disable loading
15261526
native addons. When `--no-addons` is specified, calling `process.dlopen` or
15271527
requiring a native C++ addon will fail and throw an exception.
15281528

1529+
### `--no-async-context-frame`
1530+
1531+
<!-- YAML
1532+
added: REPLACEME
1533+
-->
1534+
1535+
> Stability: 2 - Stable
1536+
1537+
Disables the use of [`AsyncLocalStorage`][] backed by `AsyncContextFrame` and
1538+
uses the prior implementation which relied on async\_hooks. The previous model
1539+
is retained for compatibility with Electron and for cases where the context
1540+
flow may differ. However, if a difference in flow is found please report it.
1541+
15291542
### `--no-deprecation`
15301543

15311544
<!-- YAML
@@ -2813,7 +2826,6 @@ one is included in the list below.
28132826
* `--enable-network-family-autoselection`
28142827
* `--enable-source-maps`
28152828
* `--experimental-abortcontroller`
2816-
* `--experimental-async-context-frame`
28172829
* `--experimental-default-type`
28182830
* `--experimental-detect-module`
28192831
* `--experimental-eventsource`
@@ -2857,6 +2869,7 @@ one is included in the list below.
28572869
* `--napi-modules`
28582870
* `--network-family-autoselection-attempt-timeout`
28592871
* `--no-addons`
2872+
* `--no-async-context-frame`
28602873
* `--no-deprecation`
28612874
* `--no-experimental-fetch`
28622875
* `--no-experimental-global-customevent`

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 {
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
@@ -518,10 +518,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
518518
AddOption(
519519
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
520520
AddOption("--expose-gc", "expose gc extension", V8Option{}, kAllowedInEnvvar);
521-
AddOption("--experimental-async-context-frame",
521+
AddOption("--async-context-frame",
522522
"Improve AsyncLocalStorage performance with AsyncContextFrame",
523523
&EnvironmentOptions::async_context_frame,
524-
kAllowedInEnvvar);
524+
kAllowedInEnvvar,
525+
true);
525526
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
526527
AddOption("--frozen-intrinsics",
527528
"experimental frozen intrinsics support",

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

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

43-
describe('AsyncContextFrame', {
44-
concurrency: tests.length
43+
describe('without AsyncContextFrame', {
44+
// TODO(qard): I think high concurrency causes memory problems on Windows
45+
// concurrency: tests.length
4546
}, () => {
4647
for (const test of tests) {
4748
it(test, async () => {
4849
const proc = spawn(python, [
4950
testRunner,
50-
'--node-args=--experimental-async-context-frame',
51+
'--node-args=--no-async-context-frame',
5152
test,
5253
], {
5354
stdio: ['ignore', 'ignore', 'inherit'],

0 commit comments

Comments
 (0)