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

[FIX] soomsilClient.response.interceptor 무한 루프 문제 #209

Closed
nijuy opened this issue Jun 4, 2024 · 0 comments · Fixed by #210
Closed

[FIX] soomsilClient.response.interceptor 무한 루프 문제 #209

nijuy opened this issue Jun 4, 2024 · 0 comments · Fixed by #210
Assignees
Labels
bug Something isn't working fix

Comments

@nijuy
Copy link
Collaborator

nijuy commented Jun 4, 2024

ISSUE ✅ : BUG

📖 Summary

쿠키에 유효하지 않은 refreshToken만 남아있을 경우, 무한 루프에 빠짐

Error Script

재현 방법

  1. 로그인 한다
  2. 쿠키에 있는 accessToken을 삭제한다
  3. 스웨거에 가서 로그인 한다 (새 토큰이 발급되면서 쿠키에 있는 refreshToken이 사용 불가 상태가 됨)
  4. 새로고침 한다
  5. 콘솔을 확인한다 (실패한 요청 -> refresh 쌍이 무한 반복)
const onRejected = async (error: AxiosError) => {
  const originalConfig = error.config;
  const data = error.response?.data as AuthErrorData;

  if (originalConfig && error.response?.status === 401 && data?.error === 'Auth-002') {
    try {
      await refreshToken(); // 여기서 에러가 나도
      return soomsilClient.request({ // 무조건 요청 다시 보내니까 다시 401 -> refresh -> ... 반복인 거 같음
        ...originalConfig,
        headers: {
          Authorization: `Bearer ${api.getAccessToken()}`,
        },
      });
    } catch (error) {
      return Promise.reject(error);
    }
  }
  return Promise.reject(error);
};

Photo

image
refreshToken_expired

@nijuy nijuy added bug Something isn't working fix labels Jun 4, 2024
@nijuy nijuy self-assigned this Jun 4, 2024
@nijuy nijuy changed the title [FIX] soomsil.response.interceptor 무한 루프 문제 [FIX] soomsilClient.response.interceptor 무한 루프 문제 Jun 4, 2024
@nijuy nijuy linked a pull request Jun 15, 2024 that will close this issue
1 task
nijuy added a commit that referenced this issue Jun 22, 2024
nijuy added a commit that referenced this issue Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant