Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axiosでtimeout時にretryさせるようにする #393

Open
kobakazu0429 opened this issue Aug 22, 2019 · 2 comments
Open

axiosでtimeout時にretryさせるようにする #393

kobakazu0429 opened this issue Aug 22, 2019 · 2 comments

Comments

@kobakazu0429
Copy link
Member

timeout時に延々CircleSpinnerが回るのは悲しい

そもそもtimeout 1000msが短いかも
https://github.com/kure-kosen/cho_kure_web/blob/feature/react/frontend/src/api/RestClient.ts#L13

@kobakazu0429
Copy link
Member Author

kobakazu0429 commented Oct 31, 2019

c.f. axios/axios#934 (comment)

上記だとミスるとリトライし続けてセルフdos攻撃になりそう
retryフラグを手動で設定すると、axios側で不明なkeyをデリートしてるみたいで失敗した
雑に書くとこんな感じ

axios.interceptors.response.use(
  response => response,
  error => {
    if (error.config) {
      return axios.request({ ...error.config, retry: 1 });
    }
    return Promise.reject(error);
  }
);

axios.interceptors.request.use(
  request => {
    if(retryフラグ) return null;
    return request;
  },
  error => {
    return error;
  }
);

@kobakazu0429
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant