mirror of https://github.com/Siphonay/mastodon
Mute XHR abort errors (#31952)
This commit is contained in:
parent
a791274824
commit
7740f1a6bb
|
@ -1,5 +1,7 @@
|
||||||
import { defineMessages } from 'react-intl';
|
import { defineMessages } from 'react-intl';
|
||||||
|
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
unexpectedTitle: { id: 'alert.unexpected.title', defaultMessage: 'Oops!' },
|
unexpectedTitle: { id: 'alert.unexpected.title', defaultMessage: 'Oops!' },
|
||||||
unexpectedMessage: { id: 'alert.unexpected.message', defaultMessage: 'An unexpected error occurred.' },
|
unexpectedMessage: { id: 'alert.unexpected.message', defaultMessage: 'An unexpected error occurred.' },
|
||||||
|
@ -50,6 +52,11 @@ export const showAlertForError = (error, skipNotFound = false) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An aborted request, e.g. due to reloading the browser window, it not really error
|
||||||
|
if (error.code === AxiosError.ECONNABORTED) {
|
||||||
|
return { type: ALERT_NOOP };
|
||||||
|
}
|
||||||
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
return showAlert({
|
return showAlert({
|
||||||
|
|
|
@ -42,6 +42,9 @@ const authorizationTokenFromInitialState = (): RawAxiosRequestHeaders => {
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default function api(withAuthorization = true) {
|
export default function api(withAuthorization = true) {
|
||||||
return axios.create({
|
return axios.create({
|
||||||
|
transitional: {
|
||||||
|
clarifyTimeoutError: true,
|
||||||
|
},
|
||||||
headers: {
|
headers: {
|
||||||
...csrfHeader,
|
...csrfHeader,
|
||||||
...(withAuthorization ? authorizationTokenFromInitialState() : {}),
|
...(withAuthorization ? authorizationTokenFromInitialState() : {}),
|
||||||
|
|
Loading…
Reference in New Issue