-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
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 DOMException
s 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 DOMException
s 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?