Skip to content

Commit 5500ae9

Browse files
Stephen BelangerMylesBorins
Stephen Belanger
authored andcommitted
domain: do not add domain to promise from other context
PR-URL: #39135 Backport-PR-URL: #39742 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent fc29ddb commit 5500ae9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/domain.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const {
3636
Error,
3737
FunctionPrototypeCall,
3838
ObjectDefineProperty,
39+
Promise,
3940
ReflectApply,
4041
SafeMap,
4142
Symbol,
@@ -73,12 +74,14 @@ const asyncHook = createHook({
7374
if (process.domain !== null && process.domain !== undefined) {
7475
// If this operation is created while in a domain, let's mark it
7576
pairing.set(asyncId, process.domain[kWeak]);
76-
ObjectDefineProperty(resource, 'domain', {
77-
configurable: true,
78-
enumerable: false,
79-
value: process.domain,
80-
writable: true
81-
});
77+
if (type !== 'PROMISE' || resource instanceof Promise) {
78+
ObjectDefineProperty(resource, 'domain', {
79+
configurable: true,
80+
enumerable: false,
81+
value: process.domain,
82+
writable: true
83+
});
84+
}
8285
}
8386
},
8487
before(asyncId) {

0 commit comments

Comments
 (0)