1

While using Axios for making API requests, encountering a situation where the request gets aborted if the user navigates to another tab or refreshes the page during the API call. The problem arises when this aborted request results in an unhandled error, which Sentry consumes, causing an increase in error counts. Can someone help me by sharing the way to handle the request aborted error, which sentry should not consume as an unhandled error?

Expected Behavior:
The Axios request should handle scenarios where the user navigates away or refreshes the page, preventing the error from being flagged as unhandled in Sentry.

Actual Behavior:
The Axios request is being aborted, leading to an unhandled error that Sentry captures and logs.

Code Reference in the axios file:

// Handle browser request cancellation (as opposed to a manual cancellation)
request.onabort = function handleAbort() {
  if (!request) {
    return;
  }

  reject(createError('Request aborted', config, 'ECONNABORTED', request));

  // Clean up request
  request = null;
};

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.