From e2fd015cdaaba683042a1b974f8c6c486aef521a Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Mon, 5 Jul 2021 15:15:30 -0700 Subject: [PATCH] domain: do not add domain to promise from other context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/39135 Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: Gerhard Stöbich --- lib/domain.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/domain.js b/lib/domain.js index 74cd59c54e705b..85f9eed2243295 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -36,6 +36,7 @@ const { Error, FunctionPrototypeCall, ObjectDefineProperty, + Promise, ReflectApply, SafeMap, Symbol, @@ -73,12 +74,14 @@ 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]); - ObjectDefineProperty(resource, 'domain', { - configurable: true, - enumerable: false, - value: process.domain, - writable: true - }); + if (type !== 'PROMISE' || resource instanceof Promise) { + ObjectDefineProperty(resource, 'domain', { + configurable: true, + enumerable: false, + value: process.domain, + writable: true + }); + } } }, before(asyncId) {