Skip to content

Commit f76d251

Browse files
author
Stephen Belanger
committed
domain: do not add domain to promise from other context
1 parent e469ca6 commit f76d251

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)