diff options
author | Stephen Belanger <stephen.belanger@datadoghq.com> | 2021-07-21 09:37:51 -0700 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2021-07-23 03:54:33 +0000 |
commit | 3fb484f4e3e5944be445203a38520ef91e96de4e (patch) | |
tree | 9e522f7b5dfb455cb0aecce2dcc8639056ce244a /lib | |
parent | f88da657f12f47879a423eaf48c6414e6f8a64fa (diff) | |
download | node-new-3fb484f4e3e5944be445203a38520ef91e96de4e.tar.gz |
lib: comment explaining special-case handling of promises
Promise handling is special-cased for domains and trace_events.
Domains must not add the `domain` property to promises in other
contexts, and trace_events must be emitted from JavaScript as
promises no longer have an AsyncWrap type attached to them.
PR-URL: https://github.com/nodejs/node/pull/39135
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/domain.js | 2 | ||||
-rw-r--r-- | lib/internal/trace_events_async_hooks.js | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/domain.js b/lib/domain.js index 85f9eed224..fcc8bb0a6d 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -74,6 +74,8 @@ const asyncHook = createHook({ if (process.domain !== null && process.domain !== undefined) { // If this operation is created while in a domain, let's mark it pairing.set(asyncId, process.domain[kWeak]); + // Promises from other contexts, such as with the VM module, should not + // have a domain property as it can be used to escape the sandbox. if (type !== 'PROMISE' || resource instanceof Promise) { ObjectDefineProperty(resource, 'domain', { configurable: true, diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js index 9a2db5aeee..482a635f25 100644 --- a/lib/internal/trace_events_async_hooks.js +++ b/lib/internal/trace_events_async_hooks.js @@ -31,6 +31,8 @@ const kEnabled = Symbol('enabled'); // twice the async_wrap.Providers list is used to filter the events. const nativeProviders = new SafeSet(ObjectKeys(async_wrap.Providers)); const typeMemory = new SafeMap(); + +// Promises are not AsyncWrap resources so they should emit trace_events here. nativeProviders.delete('PROMISE'); function createHook() { |