Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: make ALS default to AsyncContextFrame #55552

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/async_context_frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ 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
}, () => {
for (const test of tests) {
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'],
Expand Down
Loading