domain: do not add domain to promise from other context

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>
This commit is contained in:
Stephen Belanger 2021-07-05 15:15:30 -07:00 committed by Node.js GitHub Bot
parent 37d5739e0c
commit f88da657f1

View File

@ -36,6 +36,7 @@ const {
Error, Error,
FunctionPrototypeCall, FunctionPrototypeCall,
ObjectDefineProperty, ObjectDefineProperty,
Promise,
ReflectApply, ReflectApply,
SafeMap, SafeMap,
Symbol, Symbol,
@ -73,6 +74,7 @@ const asyncHook = createHook({
if (process.domain !== null && process.domain !== undefined) { if (process.domain !== null && process.domain !== undefined) {
// If this operation is created while in a domain, let's mark it // If this operation is created while in a domain, let's mark it
pairing.set(asyncId, process.domain[kWeak]); pairing.set(asyncId, process.domain[kWeak]);
if (type !== 'PROMISE' || resource instanceof Promise) {
ObjectDefineProperty(resource, 'domain', { ObjectDefineProperty(resource, 'domain', {
configurable: true, configurable: true,
enumerable: false, enumerable: false,
@ -80,6 +82,7 @@ const asyncHook = createHook({
writable: true writable: true
}); });
} }
}
}, },
before(asyncId) { before(asyncId) {
const current = pairing.get(asyncId); const current = pairing.get(asyncId);