Skip to content

process.domain is undefined after using "await" in node7  #10724

Closed
@zkd8907

Description

@zkd8907
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    domainIssues and PRs related to the domain subsystem.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions