sentry-javascript: Are DOMExceptions handled differently than normal errors?
- 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
Package + Version
-
@sentry/browser
Version:
4.2.1
Description
We have some code in our application that takes advantage of the abortable fetch API. This a native feature in many recent browsers, and there are polyfills for those browsers that don’t support it.
The recommended usage is something like this. The idea is that you fire a signal that you’ve attached to a fetch request, and if the fetch is still pending, it rejects with a DOMException whose .name is AbortError.
Our particular implementation looks like this:
let searchAbortController = null;
const emptyMap = Map();
const makeSearchCall = async (parameters, dispatch) => {
// Create a new AbortController for the context of this request
searchAbortController = new AbortController();
let response;
try {
response = await dispatch(apiFetchThunk(
'/api/endpoint/',
{ signal: searchAbortController.signal },
));
} catch (error) {
// TODO: figure out why DOMExceptions are occasionally leaking
// to Sentry.
// We don't want to do anything if the error is an abort,
// since we only abort intentionally
if (
(error.name === 'AbortError')
|| (error instanceof DOMException)
) {
return emptyMap;
}
throw error;
}
// ...
};
Near as I can tell, any DOMExceptions should be swallowed, and that’s the behavior on my local dev environment, and that’s true even when I’ve got the Sentry DSN pointed at one of our Sentry projects.
We still see errors come through, however: AbortError: The user aborted a request.. We don’t want these to hit Sentry, because we explicitly don’t care about them.
My question: is there something about the way that DOMExceptions are created, propagated, and handled that would cause this behavior? Is this expected? If it is, how do we change our application code to get around it?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (13 by maintainers)
@kamilogorek yep, I will. Thanks buddy!
Just JavaScript stuff I guess 😄 Maybe some Chrome Extension is taking over global error handler or something? You may want to add debug/beforeSend with console.log and run it in incognito mode. Or maybe build a project and use
serveto run it and see if it makes any difference.Gotcha. I knew about
ignoreErrors, but my concern is that that’s a gliobal ignore, where I was really wanting to make sure that there wasn’t something I could do to fix this particular case.There’s also still a possibility that there’s a bug in our code. Thank you for your response!