I’m using Sentry to catch errors in my React app. I’ve come to realize that errors with 502 and 504 HTTP codes are ignored by Sentry. While trying to debug it, I’ve realized that some React errors are ignored too. I don’t know why and I’d like to override this behavior.
Here’s how errors are handled in my ErrorBoundary :
componentDidCatch(error: unknown, _errorInfo: unknown): void {
// eslint-disable-next-line no-console
console.log("TESTING. error : ", error, " , error info : ", _errorInfo);
Sentry.captureException(error);
}
Here’s my init function :
Sentry.init({
dsn: "<mydsn>",
integrations: [
new Integrations.BrowserTracing(),
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
new HttpClientIntegration({
failedRequestStatusCodes: [502, 504],
}) as unknown as Integration,
],
tracesSampleRate: 1.0,
enabled: true,
release: process.env.REACT_APP_BUILD_TAG,
});
And here’s an example of log inside this function :
Error: Objects are not valid as a React child(…)
This error is not captured by Sentry while it should be in my mind.
2
Answers
I can advise you to check your _error.js file for any exclusions. For instance, you may not be logging 404 errors.
You may also want to check your init method. Sentry has ‘ignoreErrors’ option.
Last but not least, check for whitelistUrls. E.x.
Source: https://blog.sentry.io/tips-for-reducing-javascript-error-noise/
Sentry should be capturing all errors but has server-side filters for some react errors in place that can be quite noisy but don’t provide any real value, for example, hydration errors.
To make sure that the SDK is ready to capture your errors your should first check whether
Sentry.init()
is called before any other code in your app. Additionaly, you can turn on thedebug
option for logs.