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

Script won't exit "naturally" with ANR active #10023

Closed
3 tasks done
joshkel opened this issue Jan 2, 2024 · 3 comments · Fixed by #10064
Closed
3 tasks done

Script won't exit "naturally" with ANR active #10023

joshkel opened this issue Jan 2, 2024 · 3 comments · Fixed by #10064

Comments

@joshkel
Copy link
Contributor

joshkel commented Jan 2, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.91.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

 Sentry.init({
    dsn: process.env.SENTRY_DSN,
    integrations: [new Sentry.Integrations.Anr()],
  });

Steps to Reproduce

import * as Sentry from '@sentry/node';

function configureSentry() {
  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    integrations: [new Sentry.Integrations.Anr()],
  });
}

async function main() {
  configureSentry();
  await new Promise(resolve => setTimeout(resolve, 1000));
}

main();

Expected Result

The program cleanly exits after 1 second.

Actual Result

The program waits forever.

It appears that the ANR integration's timer keeps the program alive, and its unref call therefore has no effect.

This is easy to work around with an explicit process.exit() call. If this behavior is intended, then perhaps the docs should be updated?

See also #10022.

@timfish
Copy link
Collaborator

timfish commented Jan 2, 2024

Apologies, I didn't notice this in testing. Thanks for reporting it!

@timfish
Copy link
Collaborator

timfish commented Jan 2, 2024

Closing as a duplicate of #10022 since it was first

@joshkel
Copy link
Contributor Author

joshkel commented Jan 4, 2024

@timfish, I'm still able to reproduce this issue in Sentry's develop branch, even after merging #10035. The event handlers on worker appear to be enough to keep the process alive, even after calling .unref().

After #10035, I'm able to use process.exit() to explicitly exit, so this is not an urgent issue for us, but it may be worth calling out in the docs.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants