Fix/#350 자동로그인 오류 해결#355
Hidden character warning
Conversation
dev-domo
left a comment
There was a problem hiding this comment.
잘 봤습니다! reissue 메서드에서 Task 상태를 점검하는 로직 좋은 것 같아요!
그런데 fetchAuthReissue 메서드에서 Alamofire가 제공하는 responseDecodable을 활용하잖아요? 찾아보니까 responseDecodable은 아래처럼 구현되어있어요.
responseDecodable이 디폴트로 메인 큐를 활용한다는 뜻인 것 같은데, 그렇다면 이 로직이 액터 외부에서 실행되는 건 아닐지 궁금합니다. 한 번 확인을 부탁드릴게요!
더불어 현재 develop 브랜치 작업에서 reissue 메서드를 살펴보면 아래와 같은 노란색 에러가 있어요.
제가 강의를 통해 듣기로는 클로저에 캡처된 값(여기서는 self)은 Sendable해야 하는 것으로 알고 있는데 아마 현재는 클로저에 캡처된 self가 Sendable하지 않아 저런 노란색 에러가 있는 것 같아요. 이것도 확인 부탁드리겠습니다!
juri123123
left a comment
There was a problem hiding this comment.
고생하셨습니다! 코멘트 확인 한 번만 부탁드려요 ~
| AF.request( | ||
| AuthAPI.reissue(header: header).requestURL, | ||
| method: AuthAPI.reissue(header: header).method, | ||
| parameters: AuthAPI.reissue(header: header).bodyParameters, | ||
| encoding: AuthAPI.reissue(header: header).parameterEncoding, | ||
| headers: AuthAPI.reissue(header: header).headers.value | ||
| ) |
There was a problem hiding this comment.
이 부분 API.reissue()로 인해서 같은 객체가 계속 재생성되는 것 같은데 확인 부탁드려요 !
| NotificationCenter.default.post(name: .navigateLoginViewController, object: nil) | ||
|
|
||
| Task { | ||
| await self.debugTokenReissueSuccess(data) |
There was a problem hiding this comment.
이 친구가 하는 역할이 단순 디버그가 아니라면 함수명을 더 직관적으로 바꿔주면 좋을 것 같아요!
|
|
||
| case .failure(let error): | ||
| Task { | ||
| await self.debugTokenReissueFailure() |
| DispatchQueue.main.async { | ||
| NotificationCenter.default.post(name: .navigateLoginViewController, object: nil) | ||
| } |
There was a problem hiding this comment.
이 친구만 concurrency를 사용하지 않은 이유가 궁금해요 !
| ) | ||
| .validate() | ||
| .responseDecodable(of: BaseResponse<TokenReissueResponseDTO>.self) { [weak self] response in | ||
| guard let self else { return } |
There was a problem hiding this comment.
여기서 continuation resume이 안되고 있어요 ! 누수가 발생할 가능성이 있어보입니다
🔗 연결된 이슈
📄 작업 내용
💻 주요 코드 설명
문제 원인 분석
로그가 너무 길어서 ;; 요약으로 대체합니다
여튼 요약하자면 autologin 함수에서 토큰 재발급을 잘 받았는데, 거의 동시에 호출되는 notification-tokens api에는 만료된 액세스토큰이 들어가게 되어 reissue를 호출하게 됩니다. 그러면 이미 새 토큰을 받았는데 만료된 토큰으로 reissue를 호출하게 되면 또 401에러가 나게 됩니다.. 이때 clearKeychain이 실행되게 되면서 앞으로 자동로그인을 할 수 없게 됩니다 (키체인에 토큰이 있는지 확인하기 때문에)
동시성의 문제라고 판단하고 actor로 TokenService를 리팩토링했습니다 어렵더라구여 .. .. .
코드 설명
아직 근데 너무 어렵네요 actor가 ..
📚 참고자료
https://dawning-record.tistory.com/132
https://sujinnaljin.medium.com/swift-actor-%EB%BF%8C%EC%8B%9C%EA%B8%B0-249aee2b732d
https://yunie-studylog.tistory.com/81