Skip to content

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

Closed
@joshkel

Description

@joshkel

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.

Metadata

Metadata

Assignees

Labels

Package: nodeIssues related to the Sentry Node SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions