-
-
Couldn't load subscription status.
- Fork 1.7k
Closed
Labels
Milestone
Description
Problem Statement
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
onFatalErrorhandler 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:
type OnUncaughtExceptionMode = 'exit' | 'continue' | (firstError: Error, secondError?: Error) => boolean;
// default, matches node.js
new OnUncaughtException({
onException: 'exit'
});
new OnUncaughtException({
onException: 'continue'
});
new OnUncaughtException({
onException: (error) => {
// do something
// return `true` to exit the process, any other return value will keep it running
return true;
}
});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