-
-
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
Documentation suggestion: warn about using onFatalError
#2796
Comments
I'm also curious if there's any way to achieve the use case I outlined above without breaking error reporting.
Idea: what if the |
Just hit this same issue, use case is adding more contextual logging to the fatal error. |
I just hit a similar but related issue that would have been much easier to understand with more documentation. This older issue spells out the intent better then the docs: #1661 (comment) Perhaps the overlap here is more evidence of how documentation can be improved here? |
@OliverJAsh @JamesHagerman updated the docs - getsentry/sentry-docs#2643 @JCMais every fatal error is already marked as such with
This will let you modify the log message with ease if you need to: Sentry.init({
beforeSend(event) {
if (event.level === 'fatal') {
// modify the event
}
return event;
}
}); or do the above with event processors instead. Feel free to let me know if it's not sufficient and I'll happily reopen this issue. Cheers! |
Package + Version
@sentry/browser
@sentry/node
raven-js
raven-node
(raven for node)Version:
Description
For the longest time I've been passing an
onFatalError
option where I do something along the lines of what Raven used to do:https://github.com/getsentry/raven-node/blob/56a588e3deab4494c6f41e14ed906f3d40511781/lib/client.js#L86-L89
(For context, the only reason I did this was just because I wanted to prefix the logged error message with "fatal error", to differentiate them from non-fatal errors we choose to log.)
However, just today I noticed that uncaught exceptions were not being reported to Sentry. After some debugging it seemed to be because of my custom
onFatalError
. In the latest version of@sentry/node
, the defaultonFatalError
only kills the process when all events have finished sending:sentry-javascript/packages/node/src/integrations/onuncaughtexception.ts
Line 57 in d716bd9
sentry-javascript/packages/node/src/handlers.ts
Lines 430 to 453 in 7956bd8
By passing a custom
onFatalError
I was unintentionally overriding this behaviour, thus the event never reached Sentry because the process was killed before the event was sent.For this reason, I think the docs for
onFatalError
should carry a big warning—that by customising this functionality, you lose this important facility. WDYT?The text was updated successfully, but these errors were encountered: