-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Package: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDK
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.5.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
const sentryConfig: Sentry.NodeOptions = {
dsn: process.env.SENTRY_DSN,
environment: process.env.ENVIRONMENT,
integrations: [
Sentry.onUnhandledRejectionIntegration({
mode: 'strict',
}),
],
};
Sentry.init(sentryConfig);Steps to Reproduce
Trigger an unhandled promise rejection while using the onUnhandledRejectionIntegration in mode: 'strict'.
Expected Result
For the app to exit gracefully.
Actual Result
When Sentry's onUnhandledRejectionIntegration catches an unhandled promise rejection in strict mode, it is currently designed to exit immediately:
| global.process.exit(1); |
This does not allow the app to shut things down and exit gracefully, because it bypasses any SIGTERM listeners. The code should really be designed like so:
if (process.listenerCount('SIGTERM')) {
global.process.kill(process.pid, 'SIGTERM');
} else {
global.process.exit(1);
}This will detect if there are any SIGTERM listeners, and if so, rely on those to handle shut down and exit.
Metadata
Metadata
Assignees
Labels
Package: nodeIssues related to the Sentry Node SDKIssues related to the Sentry Node SDK
Projects
Status
No status