Skip to content

Commit

Permalink
domain: do not add domain to promise from other context
Browse files Browse the repository at this point in the history
PR-URL: nodejs#39135
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
  • Loading branch information
Qard committed Aug 12, 2021
1 parent 2f88a81 commit 0cb2c24
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/domain.js
Expand Up @@ -36,6 +36,7 @@ const {
Error,
FunctionPrototypeCall,
ObjectDefineProperty,
Promise,
ReflectApply,
SafeMap,
Symbol,
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0cb2c24

Please sign in to comment.