Feat(#292): react-query 전역 mutation 에러 토스트 안전망 추가#295
Open
stringnine wants to merge 1 commit into
Open
Conversation
- MutationCache.onError로 개별 처리되지 않은 mutation 실패를 전역 토스트 표시 - meta.suppressGlobalErrorToast 옵트아웃 + 에러 페이지 리다이렉트 시 토스트 생략으로 중복 방지 - 원시 기술 메시지 노출 방지 (meta.errorMessage → 서버 message → 기본 문구 순 추출) - 쿼리 retry 정책: 4xx 비재시도, 그 외 2회 재시도 - 자체 피드백 있는 mutation 6종(크레딧/구독/노트 생성·벌크삭제) 옵트아웃 처리 - client.ts: getErrorRedirectRoute 헬퍼 export
📝 WalkthroughWalkthrough전역 MutationCache.onError 핸들러를 추가하여 처리되지 않은 mutation 실패 시 자동으로 토스트를 표시하고, suppressGlobalErrorToast 메타 플래그와 getErrorRedirectRoute 헬퍼로 중복 표시를 방지하며, 개별 뮤테이션에서 선택적으로 억제한다. Changes전역 mutation 에러 처리 및 안전망
Sequence DiagramsequenceDiagram
participant Mutation as Mutation<br/>(실패)
participant MutationCache as MutationCache<br/>.onError
participant CheckSuppress as suppressGlobalErrorToast<br/>체크
participant CheckRedirect as getErrorRedirectRoute<br/>체크
participant ResolveMsg as resolveErrorMessage<br/>메시지 추출
participant Toast as showErrorToast<br/>(표시)
Mutation->>MutationCache: 실패 발생
MutationCache->>CheckSuppress: meta.suppressGlobalErrorToast 확인
CheckSuppress-->>MutationCache: true면 중단
MutationCache->>CheckRedirect: getErrorRedirectRoute(error) 호출
CheckRedirect-->>MutationCache: 리다이렉트 경로<br/>(있으면 중단, 없으면 계속)
MutationCache->>ResolveMsg: 에러 메시지 추출
ResolveMsg-->>MutationCache: data.message 또는<br/>DEFAULT_ERROR_MESSAGE
MutationCache->>Toast: 메시지와 함께 토스트 표시
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 관련 이슈
🏷️ PR 타입
📝 작업 내용
개별 처리되지 않은 mutation 실패가 조용히 사라지던 문제를 막기 위해 react-query 전역 에러 토스트 안전망을 추가했습니다.
MutationCache.onError추가 → 개별 처리되지 않은 mutation 실패를 자동으로 에러 토스트 표시meta.suppressGlobalErrorToast옵트아웃 → 호출부에서 자체 에러 UI를 표시하는 mutation은 제외getErrorRedirectRoute)meta.errorMessage→ 서버message→ 안전한 기본 문구 순으로 추출mutationMeta타입 보강client.ts:getErrorRedirectRoute()헬퍼 export (기존 리다이렉트 판단 로직 재사용)옵트아웃 처리한 mutation (자체 피드백 존재 → 중복 방지)
useUseCredituseCancelSubscription/useResumeSubscriptionuseUpgradeSubscriptionuseDeleteNotesBulkuseCreateNote새로 안전망이 적용된 곳 (기존엔 조용히 실패)
useDeleteNote(RecentNotes),useUpdateNoteTitle(SidebarNoteItem)의catch {}→ 이제 실패 시 토스트 표시✅ 체크리스트
공통
pnpm tsc --noEmit타입 체크를 통과했습니다type/이슈번호-작업명)📎 기타 참고사항
Summary by CodeRabbit