Skip to content

Application Not Responding (ANR) feature breaks use with PM2 #9131

@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.72.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

  Sentry.init({
    dsn: process.env.SENTRY_DSN,
    release: getSentryReleaseIdentifier(),
    environment: process.env.SITE_NAME?.toLowerCase() || undefined,
    initialScope: {
      tags: { commit: version?.commitSha },
    },
  });

Steps to Reproduce

  1. Enable the new Application Not Responding feature:

    await Sentry.enableAnrDetection({ captureStackTrace: true });
  2. Configure the application to run within PM2.

Expected Result

The application works.

Actual Result

Sentry's ANR feature thinks that the application is the ANR watchdog child (because the process has been forked by PM2 and therefore has a process.send), so it doesn't work. (In my local testing, it causes PM2 to treat the process as terminated by SIGINT.)

I could provide a separate entryScript, but that wouldn't help the issue of the parent process thinking it's the child. I think I could delete process.send, but that seems like a hack (and can break PM2 features). Maybe enableAnrDetection needs some sort of "force" parameter? Maybe it should assume it's the parent (ignoring process.send) if an entryScript is provided and/or if entryScript !== process.arg[1]?

Metadata

Metadata

Assignees

Labels

Package: nodeIssues related to the Sentry Node SDK

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions