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 @@ -2063,17 +2063,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 @@ -3927,7 +3916,6 @@ one is included in the list below.
* `--max-old-space-size-percentage`
* `--network-family-autoselection-attempt-timeout`
* `--no-addons`
* `--no-async-context-frame`
* `--no-deprecation`
* `--no-experimental-global-navigator`
* `--no-experimental-sqlite`
Expand Down Expand Up @@ -4538,7 +4526,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 @@ -115,10 +115,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 @@ -1089,12 +1089,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 @@ -2078,8 +2072,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 @@ -287,9 +287,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
3 changes: 1 addition & 2 deletions lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const before_symbol = Symbol('before');
const after_symbol = Symbol('after');
const destroy_symbol = Symbol('destroy');
const promise_resolve_symbol = Symbol('promiseResolve');
const async_local_storage_context_symbol = Symbol('kAsyncLocalStorageContext');
const emitBeforeNative = emitHookFactory(before_symbol, 'emitBeforeNative');
const emitAfterNative = emitHookFactory(after_symbol, 'emitAfterNative');
const emitDestroyNative = emitHookFactory(destroy_symbol, 'emitDestroyNative');
Expand Down Expand Up @@ -585,7 +584,7 @@ module.exports = {
symbols: {
async_id_symbol, trigger_async_id_symbol,
init_symbol, before_symbol, after_symbol, destroy_symbol,
promise_resolve_symbol, async_local_storage_context_symbol,
promise_resolve_symbol,
owner_symbol,
},
constants: {
Expand Down
168 changes: 0 additions & 168 deletions lib/internal/async_local_storage/async_hooks.js

This file was deleted.

11 changes: 2 additions & 9 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ const {
emitBefore,
emitAfter,
emitDestroy,
symbols: {
async_local_storage_context_symbol,
},
} = require('internal/async_hooks');

// Symbols for storing async id state.
Expand Down Expand Up @@ -132,12 +129,8 @@ const AsyncContextFrame = require('internal/async_context_frame');
const async_context_frame = Symbol('kAsyncContextFrame');

function removeStoresFromResource(resource) {
if (AsyncContextFrame.enabled) {
if (resource[async_context_frame] !== undefined) {
resource[async_context_frame] = undefined;
}
} else if (resource[async_local_storage_context_symbol] !== undefined) {
resource[async_local_storage_context_symbol] = undefined;
if (resource[async_context_frame] !== undefined) {
resource[async_context_frame] = undefined;
}
}

Expand Down
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 @@ -751,11 +751,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",
BOOL_FIELD(async_context_frame),
kAllowedInEnvvar,
true);
AddOption("--expose-internals", "", BOOL_FIELD(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 @@ -227,7 +227,6 @@ class EnvironmentOptions : public Options {
DEFINE_BOOL_FIELD(allow_openssl_store) = false;
DEFINE_BOOL_FIELD(allow_worker_threads) = false;
DEFINE_BOOL_FIELD(experimental_vm_modules) = EXPERIMENTALS_DEFAULT_VALUE;
DEFINE_BOOL_FIELD(async_context_frame) = true;
DEFINE_BOOL_FIELD(expose_internals) = false;
DEFINE_BOOL_FIELD(force_node_api_uncaught_exceptions_policy) = false;
DEFINE_BOOL_FIELD(frozen_intrinsics) = false;
Expand Down
Loading
Loading