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
Backport-PR-URL: #39742
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 MylesBorins committed Aug 31, 2021
1 parent fc29ddb commit 5500ae9
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 5500ae9

Please sign in to comment.