You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current integration configuration for the node OnUncaughtExceptionOptions exception can be a bit confusing, especially with recently necessary changes regarding the default behavior.
Current behavior:
Following the node.js default, we exit the process on uncaught exceptions
For e.g. next.js, we need the capability to opt out of this behavior - however, we only want to opt out of it if any other handler has been registered.
Then there is also the option of providing an onFatalError handler to conditionally define if the process should exit or not
Solution Brainstorm
We could add a new option to (eventually) replace all existing options, e.g. mode.
A possible API could be:
typeOnUncaughtExceptionMode='exit'|'continue'|(firstError: Error,secondError?: Error)=>boolean;// default, matches node.jsnewOnUncaughtException({onException: 'exit'});newOnUncaughtException({onException: 'continue'});newOnUncaughtException({onException: (error)=>{// do something// return `true` to exit the process, any other return value will keep it runningreturntrue;}});
With the behaviour:
exit: Always exit the process on uncaught exceptions. The default.
continue: Do not exit the process. Could be set by the next.js integration.
a function: Leave this to the user. Can eventually replace onFatalError
My idea would be to, for now, allow to opt-in to that behavior by setting onException on the integration. If that's set, use the new logic, else, the "old" one.
Then we can think about deprecating the "old" functionality, and flipping defaults for v8. The trickiest migration/thing is the onFatalError stuff, not sure if we want to/need to keep support for that (without any changes) in the future.
Activity
mydea commentedon Nov 9, 2022
So I think the following exception handler would kind of cover all relevant cases for now:
My idea would be to, for now, allow to opt-in to that behavior by setting
onExceptionon the integration. If that's set, use the new logic, else, the "old" one.Then we can think about deprecating the "old" functionality, and flipping defaults for v8. The trickiest migration/thing is the
onFatalErrorstuff, not sure if we want to/need to keep support for that (without any changes) in the future.Thoughts, @lobsterkatie ?
We could then remove (or deprecate) the
exitEvenIfOtherHandlersAreRegisteredand instead setonException: 'continue'in the nextjs integration.Nikoms commentedon Dec 13, 2022
I agree that, by default, it shouldn't call
exit. We just updated the library and took a day to understand why our servers were killed 😅.AbhiPrasad commentedon Apr 24, 2024
Can this be closed now @lforst?
lforst commentedon Apr 25, 2024
Yes! Thanks for reminding me.