summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2023-01-27 14:03:51 -0800
committerJames M Snell <jasnell@gmail.com>2023-02-01 07:37:05 -0800
commitdc90810f9ffe4b3d8f3f6bf8608a0cd73b9b4c8f (patch)
treea9e7564c895b6eb7fd807f3251ac904c7c1f5c0c /lib
parent088e470dcdaa62310e2aed37f63cdfc84a84ac72 (diff)
downloadnode-new-dc90810f9ffe4b3d8f3f6bf8608a0cd73b9b4c8f.tar.gz
async_hooks: remove experimental onPropagate option
The `onPropagate` option for `AsyncLocalStorage` is problematic for a couple of reasons: 1. It is not expected to be forwards compatible in any way with the upcoming TC-39 `AsyncContext` proposal. 2. It introduces a non-trivial O(n) cost invoking a JavaScript callback for *every* AsyncResource that is created, including every Promise. While it is still experimental, I recommend removing it while we can revisit the fundamental use cases in light of the coming `AsyncContext` proposal. Refs: https://github.com/nodejs/node/issues/46374 PR-URL: https://github.com/nodejs/node/pull/46386 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/async_hooks.js15
1 files changed, 2 insertions, 13 deletions
diff --git a/lib/async_hooks.js b/lib/async_hooks.js
index bf76874ffe..525b69acbf 100644
--- a/lib/async_hooks.js
+++ b/lib/async_hooks.js
@@ -23,7 +23,6 @@ const {
const { kEmptyObject } = require('internal/util');
const {
validateFunction,
- validateObject,
validateString,
} = require('internal/validators');
const internal_async_hooks = require('internal/async_hooks');
@@ -275,17 +274,9 @@ const storageHook = createHook({
});
class AsyncLocalStorage {
- constructor(options = kEmptyObject) {
- validateObject(options, 'options');
-
- const { onPropagate = null } = options;
- if (onPropagate !== null) {
- validateFunction(onPropagate, 'options.onPropagate');
- }
-
+ constructor() {
this.kResourceStore = Symbol('kResourceStore');
this.enabled = false;
- this._onPropagate = onPropagate;
}
disable() {
@@ -312,9 +303,7 @@ class AsyncLocalStorage {
_propagate(resource, triggerResource, type) {
const store = triggerResource[this.kResourceStore];
if (this.enabled) {
- if (this._onPropagate === null || this._onPropagate(type, store)) {
- resource[this.kResourceStore] = store;
- }
+ resource[this.kResourceStore] = store;
}
}