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

NodejsEnvironment Dispose() is blocked by pending tasks #355

Open
camnewnham opened this issue Aug 13, 2024 · 1 comment
Open

NodejsEnvironment Dispose() is blocked by pending tasks #355

camnewnham opened this issue Aug 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working libnode
Milestone

Comments

@camnewnham
Copy link

In the following snippet, the nodejs environment starts running a task that continues indefinitely:

env.Run(() =>
    {
        JSValue.RunScript(@"
setInterval(() => {
    console.log('Hello from Node.js');
}, 1000);
");
    });

Calling env.Dispose() doesn't kill the environment but instead waits for completion (which never occurs).
Is it possible to forcefully "kill" the node environment?

@jasongin jasongin added bug Something isn't working libnode labels Aug 13, 2024
@jasongin
Copy link
Member

The NodejsEnvironment.Dispose() method should dispose the environment even if there are pending tasks such as those registered by setImmediate(). So I think this is a bug.

@vmoroz, from debugging this I can see that napi_await_promise() never returns even after the promise is definitely resolved. Is this a bug in that embedding API?

@jasongin jasongin changed the title Forceful disposal of the node environment NodejsEnvironment Dispose() is blocked by pending tasks Aug 13, 2024
@jasongin jasongin added this to the Embedding milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libnode
Projects
None yet
Development

No branches or pull requests

3 participants