Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process.domain is undefined after using "await" in node10 #20378

Closed
loviselu opened this issue Apr 28, 2018 · 2 comments
Closed

process.domain is undefined after using "await" in node10 #20378

loviselu opened this issue Apr 28, 2018 · 2 comments
Labels
async_hooks Issues and PRs related to the async hooks subsystem. confirmed-bug Issues with confirmed bugs. domain Issues and PRs related to the domain subsystem. duplicate Issues and PRs that are duplicates of other issues or PRs. promises Issues and PRs related to ECMAScript promises.

Comments

@loviselu
Copy link

Version: found at v10.0.0
Platform: 64-bit Windows 7
Subsystem:domain

When I upgrade to node v10.0.0, I found a problem with domain

Here is the 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.

Just like the problem mentioned at #10724. It happened again at node v10.0.0. Please take a look.

@apapirovski
Copy link
Contributor

This is almost certainly related to the switch to using async hooks for domains and as a result we're now affected by #20274

Unfortunately, I don't know a good way to resolve. ping @bmeurer I think we'll need to figure out a path forward with PromiseHooks because this is about to break people using domain.

@apapirovski apapirovski added confirmed-bug Issues with confirmed bugs. domain Issues and PRs related to the domain subsystem. promises Issues and PRs related to ECMAScript promises. async_hooks Issues and PRs related to the async hooks subsystem. labels Apr 28, 2018
@addaleax addaleax added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Apr 29, 2018
@addaleax
Copy link
Member

I'm closing this as a duplicate of #20274, so that we don't spread out the conversation over too many places

Thanks for reporting this!

@nodejs nodejs deleted a comment Sep 17, 2023
@nodejs nodejs deleted a comment Sep 17, 2023
@nodejs nodejs deleted a comment Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem. confirmed-bug Issues with confirmed bugs. domain Issues and PRs related to the domain subsystem. duplicate Issues and PRs that are duplicates of other issues or PRs. promises Issues and PRs related to ECMAScript promises.
Projects
None yet
Development

No branches or pull requests

3 participants