-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Improve node OnUncaughtException
integration
#6146
Comments
So I think the following exception handler would kind of cover all relevant cases for now: const onExceptionHandler = (error: Error): void => {
const { onException } = this._options;
const hub = getCurrentHub();
if (hub.getIntegration(OnUncaughtException)) {
hub.withScope((scope: Scope) => {
scope.setLevel('fatal');
hub.captureException(error, {
originalException: error,
data: { mechanism: { handled: false, type: 'onuncaughtexception' } },
});
});
}
if (onException === 'exit') {
logAndExitProcess(error);
return;
}
if (onException === 'warn') {
logger.warn(`onUncaughtException integration encountered an exception: ${error}`);
return;
}
if (typeof onException === 'function') {
const result = onException(error);
if (result !== undefined) {
logAndExitProcess(result);
}
return;
}
// else: 'continue'
}; My idea would be to, for now, allow to opt-in to that behavior by setting Then we can think about deprecating the "old" functionality, and flipping defaults for v8. The trickiest migration/thing is the Thoughts, @lobsterkatie ? We could then remove (or deprecate) the |
I agree that, by default, it shouldn't call |
Can this be closed now @lforst? |
Yes! Thanks for reminding me. |
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:
onFatalError
handler to conditionally define if the process should exit or notSolution Brainstorm
We could add a new option to (eventually) replace all existing options, e.g.
mode
.A possible API could be:
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.onFatalError
The text was updated successfully, but these errors were encountered: