Anyone using Sentry without being overwhelmed by random errors?
I’ve integrated Sentry into my Next.js project, but I’m constantly bombarded with random errors that aren’t always related to my code. These include Network Errors, Request aborted, <unknown> errors and so many others.
Is there a way of handling this without manually ignoring issues?
4 Replies
I imagine there's a way of setting filters for issues you do want to see? Like searching for specific data or filtering it out
Or filtering for what Sentry reports, but I'm not confident in recommending that since aborted requests can be indicators of issues
Oof I remember encountering this years ago. I wanna say that while there probably are filters, the errors you’re being bombarded with are probably signs something else is wrong.
Probably worth following the user’s session or flow to identify what the root cause of the errors are
@faheem From my experience, rarely are errors reported in Sentry occuring at random. Source to some may be obscured by code minification, or detached if they occur in async handlers. There is tons of possibilities on what you are experiencing, but on the top of my head, from what you pointed out:
Request aborted - I think these can happen in two ways (not sure if they belong to the exact same error type):
1. You start a request, but then click a link and the request gets canceled as the browser wants to move on to new route. Totally normal, can be ignored, unless you are seeing some requests canceled that shouldn't be there in the first place.
2. You are using
AbortController
and signals in fetch requests and not catching the promise exceptions. E.g. this may happen when you are using react query signals that are passed. For those I would write catch segments that are filtering such exceptions out before propagating them upwards, since usually, abort signal is sent by design.
<unknown> - these happen usually when you throw something that is not an Error instance. Some validators do this, so pay attention where in the source the error happens.
Network error - Usually lack of internet, but also server is down, or you turned on a vpn when some request was happening.
Personally I follow the following rules to handle those errors:
- Filtering errors out is my last resort, when I am sure the error is gibberish that comes outside of my code (third party lib that does not allow me to catch an error)
- Any error coming from normal usage (related to aborting, network changes etc) I catch and handle correctly (sometimes it's showing a toast to the user, and sometimes just console.warn or console.error with better message)
- Any unknown
error gets investigated and fixed - js allows you to use anything in throw
, however, Sentry is not prepared for this. A note here - I am not sure how they are dealing with Suspense, since those work due to Promise
being thrown. I'd guess Sentry has it covered for the React lib, but worth mentioning anyway.
Couple of additional noise-canceling tips:
- Make sure you have Sentry off on local dev environment unless testing the integration specifically, or some specific errors
- Make sure you have Sentry off for running test suitesThank you everyone for your responses. I’ll do some more triaging