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 with ANR and captureStackTrace active #10022

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

Script won't exit with ANR and captureStackTrace active #10022

joshkel opened this issue Jan 2, 2024 · 7 comments · Fixed by #10035

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({captureStackTrace: true})],
  });

Steps to Reproduce

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

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

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

main();

Expected Result

The program cleanly exits after 1 second.

Actual Result

The program waits forever with the following console output:

Debugger listening on ws://127.0.0.1:55686/bf184600-b574-49d0-9b00-3640e71b55ed
For help, see: https://nodejs.org/en/docs/inspector
Waiting for the debugger to disconnect...

I can find no workaround.

@timfish
Copy link
Collaborator

timfish commented Jan 2, 2024

Thanks for reporting. Sorry, this was unexpected behaviour and therefore didn't even end up in the test cases.

@joshkel
Copy link
Contributor Author

joshkel commented Jan 2, 2024

Thanks, @timfish . I may have been unclear - #10023 and this issue are separate. #10023 is about unrefing the timer, because "natural" exit doesn't work when ANR is enabled. This issue is about explicit process.exit not working when ANR and captureStackTrace are both enabled.

@timfish
Copy link
Collaborator

timfish commented Jan 2, 2024

This issue is about explicit process.exit not working when ANR and captureStackTrace are both enabled.

Ah, thanks for the heads up. I'll test this tomorrow!

@timfish
Copy link
Collaborator

timfish commented Jan 2, 2024

I couldn't wait but I'll check again tomorrow because it's late...

With the following code and the timer fix, node exits cleanly after a second:

const Sentry = require('@sentry/node');

function configureSentry() {
  Sentry.init({
    dsn: 'https://public@dsn.ingest.sentry.io/1337',
    integrations: [new Sentry.Integrations.Anr({ captureStackTrace: false })],
  });
}

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

main();

@joshkel
Copy link
Contributor Author

joshkel commented Jan 2, 2024

@timfish I apologize; there was a bug in my test case. (That's what I get for trying to do too many things at once...)

I'm seeing the issue with captureStackTrace: true. I've updated my steps to reproduce.

@timfish
Copy link
Collaborator

timfish commented Jan 2, 2024

Oh, you're right, it doesn't actually fix it with the timer undef'd. The debugger must keep it alive 😬

@AbhiPrasad
Copy link
Member

All the ANR fixes were released with https://github.com/getsentry/sentry-javascript/releases/tag/7.92.0 - please give it a try!

Thanks for your help + contributions, appreciate it!

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