Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser
-
@sentry/node
-
raven-js
-
raven-node
(raven for node) - other:
Version:
5.15.5
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:
this.onFatalError = this.defaultOnFatalError = function (err, sendErr, eventId) {
console.error(err && err.stack ? err.stack : err);
process.exit(1);
};
(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 default onFatalError
only kills the process when all events have finished sending:
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?