Skip to content
Open
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
13 changes: 0 additions & 13 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2002,17 +2002,6 @@ 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: v24.0.0
-->

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 @@ -3825,7 +3814,6 @@ 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 Expand Up @@ -4420,7 +4408,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
[`--require`]: #-r---require-module
[`--use-env-proxy`]: #--use-env-proxy
[`--use-system-ca`]: #--use-system-ca
[`AsyncLocalStorage`]: async_context.md#class-asynclocalstorage
[`Buffer`]: buffer.md#class-buffer
[`CRYPTO_secure_malloc_init`]: https://www.openssl.org/docs/man3.0/man3/CRYPTO_secure_malloc_init.html
[`ERR_INVALID_TYPESCRIPT_SYNTAX`]: errors.md#err_invalid_typescript_syntax
Expand Down
4 changes: 0 additions & 4 deletions doc/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@
"type": "boolean",
"description": "allow worker threads when any permissions are set"
},
"async-context-frame": {
"type": "boolean",
"description": "Improve AsyncLocalStorage performance with AsyncContextFrame"
},
"conditions": {
"oneOf": [
{
Expand Down
8 changes: 0 additions & 8 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -1051,12 +1051,6 @@ Disable the \fBnode-addons\fR exports condition as well as disable loading
native addons. When \fB--no-addons\fR is specified, calling \fBprocess.dlopen\fR or
requiring a native C++ addon will fail and throw an exception.
.
.It Fl -no-async-context-frame
Disables the use of \fBAsyncLocalStorage\fR backed by \fBAsyncContextFrame\fR 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.
.
.It Fl -no-deprecation
Silence deprecation warnings.
.
Expand Down Expand Up @@ -2008,8 +2002,6 @@ one is included in the list below.
.It
\fB--no-addons\fR
.It
\fB--no-async-context-frame\fR
.It
\fB--no-deprecation\fR
.It
\fB--no-experimental-global-navigator\fR
Expand Down
4 changes: 1 addition & 3 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ class AsyncResource {
module.exports = {
// Public API
get AsyncLocalStorage() {
return AsyncContextFrame.enabled ?
require('internal/async_local_storage/async_context_frame') :
require('internal/async_local_storage/async_hooks');
return require('internal/async_local_storage/async_context_frame');
},
createHook,
executionAsyncId,
Expand Down
43 changes: 4 additions & 39 deletions lib/internal/async_context_frame.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const {
ObjectSetPrototypeOf,
SafeMap,
} = primordials;

Expand All @@ -10,11 +9,10 @@ const {
setContinuationPreservedEmbedderData,
} = internalBinding('async_context_frame');

let enabled_;

class ActiveAsyncContextFrame extends SafeMap {
static get enabled() {
return true;
class AsyncContextFrame extends SafeMap {
constructor(store, data) {
super(AsyncContextFrame.current());
this.set(store, data);
}

static current() {
Expand All @@ -35,39 +33,6 @@ class ActiveAsyncContextFrame extends SafeMap {
const frame = this.current();
frame?.disable(store);
}
}

function checkEnabled() {
const enabled = require('internal/options')
.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.
if (enabled) {
// eslint-disable-next-line no-use-before-define
ObjectSetPrototypeOf(AsyncContextFrame, ActiveAsyncContextFrame);
}

return enabled;
}

class InactiveAsyncContextFrame extends SafeMap {
static get enabled() {
enabled_ ??= checkEnabled();
return enabled_;
}

static current() {}
static set(frame) {}
static exchange(frame) {}
static disable(store) {}
}

class AsyncContextFrame extends InactiveAsyncContextFrame {
constructor(store, data) {
super(AsyncContextFrame.current());
this.set(store, data);
}

disable(store) {
this.delete(store);
Expand Down
153 changes: 0 additions & 153 deletions lib/internal/async_local_storage/async_hooks.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/async_context_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ Local<Value> current(Isolate* isolate) {
}

void set(Isolate* isolate, Local<Value> value) {
auto env = Environment::GetCurrent(isolate);
if (!env->options()->async_context_frame) {
return;
}

isolate->SetContinuationPreservedEmbedderDataV2(value);
}

Expand Down
5 changes: 0 additions & 5 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,6 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption(
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
AddOption("--expose-gc", "expose gc extension", V8Option{}, kAllowedInEnvvar);
AddOption("--async-context-frame",
"Improve AsyncLocalStorage performance with AsyncContextFrame",
&EnvironmentOptions::async_context_frame,
kAllowedInEnvvar,
true);
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
AddOption("--frozen-intrinsics",
"experimental frozen intrinsics support",
Expand Down
1 change: 0 additions & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ class EnvironmentOptions : public Options {
bool allow_worker_threads = false;
bool experimental_repl_await = true;
bool experimental_vm_modules = EXPERIMENTALS_DEFAULT_VALUE;
bool async_context_frame = true;
bool expose_internals = false;
bool force_node_api_uncaught_exceptions_policy = false;
bool frozen_intrinsics = false;
Expand Down
11 changes: 4 additions & 7 deletions test/async-hooks/test-async-local-storage-gcable.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';
// Flags: --expose_gc --expose-internals
// Flags: --expose_gc

// This test ensures that AsyncLocalStorage gets gced once it was disabled
// and no strong references remain in userland.

const common = require('../common');
const { AsyncLocalStorage } = require('async_hooks');
const AsyncContextFrame = require('internal/async_context_frame');
const { onGC } = require('../common/gc');

let asyncLocalStorage = new AsyncLocalStorage();
Expand All @@ -17,11 +16,9 @@ asyncLocalStorage.run({}, common.mustCall(() => {
onGC(asyncLocalStorage, { ongc: common.mustCall() });
}));

if (AsyncContextFrame.enabled) {
// This disable() is needed to remove reference form AsyncContextFrame
// created during exit of run() to the AsyncLocalStore instance.
asyncLocalStorage.disable();
}
// This disable() is needed to remove reference from AsyncContextFrame
// created during exit of run() to the AsyncLocalStore instance.
asyncLocalStorage.disable();

asyncLocalStorage = null;
global.gc();
4 changes: 0 additions & 4 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ test-fs-cp-sync-symlink-points-to-dest-error: SKIP
test-fs-cp-async-symlink-points-to-dest: SKIP
test-fs-cp-sync-unicode-folder-names: SKIP

# https://github.com/nodejs/node/issues/56751
test-without-async-context-frame: PASS, FLAKY

# Windows on ARM
[$system==win32 && $arch==arm64]

Expand Down Expand Up @@ -144,7 +141,6 @@ test-http-pipeline-flood: SKIP
test-inspector-network-fetch: SKIP
test-inspector-network-content-type: SKIP
test-fetch: SKIP
test-without-async-context-frame: SKIP
test-process-cpuUsage: PASS, FLAKY
test-web-locks: SKIP
test-http2-allow-http1-upgrade-ws: SKIP
Expand Down
Loading
Loading