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: #39135
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
  • Loading branch information
Stephen Belanger authored and BethGriggs committed Jul 29, 2021
1 parent b5248d4 commit e2fd015
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/domain.js
Original file line number Diff line number Diff line change
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 e2fd015

Please sign in to comment.