-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
The onUnhandledRejectionIntegration
does not exit gracefully in strict mode
#12266
Comments
Note, a temporary fix for anyone else encountering this would be to not use process.on('unhandledRejection', () => {
if (process.listenerCount('SIGTERM')) {
process.kill(process.pid, 'SIGTERM');
} else {
process.exit(1);
}
}); |
Hi, thanks for writing in. Would you mind walking me through your thought process? This is how I currently look at this issue: You manually set
As far as I can tell, you simply shouldn't set the mode to |
I can see your reasoning, and while I'd normally say adhering to the behavior of a platform like Node.js is a good idea, when it comes to exiting gracefully and signal handling, Node.js isn't the best example; there are a number of flaws with how Node.js handles signal listeners and graceful shutdown. Essentially, my reasoning is that if a program registers The workaround I suggested avoids using |
Thanks for elaborating. I think we will not change this behaviour. I don't intend to dismiss your point but there is some history 😄 From my last research on whether we can be more accurate here, I don't think there is a way to exactly match Node.js's exit behaviour when intending run IO (in our case to flush data). We certainly do not want to "improve" Node.js' behaviours - that is up to our users. I'll close this to keep our issue stream clean but feel free to reach out if you have any questions or concerns! |
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
8.5.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Trigger an unhandled promise rejection while using the
onUnhandledRejectionIntegration
inmode: '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:sentry-javascript/packages/node/src/utils/errorhandling.ts
Line 34 in 005f40d
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:This will detect if there are any
SIGTERM
listeners, and if so, rely on those to handle shut down and exit.The text was updated successfully, but these errors were encountered: