Closed
Description
- Version: found at v7.4.0, reproducible at v7.2.0
- Platform: 64-bit Windows 10, Darwin Kernel Version 16.3.0(macOS 10.12.2)
- Subsystem:domain
I am trying to transform my code from Promise to await/async in node7, but I found it didn't work with domain
.
Here is my code:
let d = require('domain').create();
d.run(async function(){
console.log(d === process.domain);
// true
console.log(1, process.domain);
// process.domain exists
let result = await (async() => {
return new Promise((resolve) => {
resolve('ok');
});
})();
console.log(result, process.domain, d);
/**
* result: ok
* process.domain: undefined
* d: no change
*/
});
As shown by the comments, process.domain
is undefined after using await
. However, If I remove await
the result will be a Promise and process.domain
is the same with d
.
Is is a bug or something undocumented.