Skip to content

[Refactor/#241] invalidateQueries 처리 기준 통일 및 retry 전략 세분화 - #260

Merged
Seojegyeong merged 4 commits into
developfrom
refactor/#241
Jun 23, 2026
Merged

[Refactor/#241] invalidateQueries 처리 기준 통일 및 retry 전략 세분화#260
Seojegyeong merged 4 commits into
developfrom
refactor/#241

Conversation

@Seojegyeong

@Seojegyeong Seojegyeong commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

🚨 관련 이슈

#241

✨ 변경사항

  • 🐞 BugFix Something isn't working
  • 💻 CrossBrowsing Browser compatibility
  • 🌏 Deploy Deploy
  • 🎨 Design Markup & styling
  • 📃 Docs Documentation writing and editing (README.md, etc.)
  • ✨ Feature Feature
  • 🔨 Refactor Code refactoring
  • ⚙️ Setting Development environment setup
  • ✅ Test Test related (storybook, jest, etc.)

✏️ 작업 내용

  1. retry 전략 세분화 (src/lib/queryClient.ts)

    • 기존 retry: 1은 4xx 에러에서도 재시도를 유발해, axiosInstance 인터셉터의 401 재발급 재시도와 중복 발생
    • 4xx: 즉시 실패 (클라이언트 오류는 재시도해도 결과 동일)
    • 5xx: 1회 재시도 허용 (서버 일시 오류 대응)
  2. invalidateQueries 사용 기준 통일

    • WorkspaceSwitcher: await 순서 교정 — setIsOpen(false)await Promise.all 뒤로 이동
    • Workspace: voidawait — 워크스페이스 생성 후 setCreateOpen(false) 이전 캐시 갱신 보장
    • MemberManagement: 멤버 삭제 onSuccess voidawait — 삭제 후 setIsDeleteModalOpen(false) 이전 캐시 갱신 보장
    • useCampaignGroup, AdsListPage: 묵시 버림 → void 명시

😅 미완성 작업

N/A

📢 논의 사항 및 참고 사항

N/A

💬 리뷰어 가이드 (P-Rules)
P1: 필수 반영 (Critical) - 버그 가능성, 컨벤션 위반. 해결 전 머지 불가.
P2: 적극 권장 (Recommended) - 더 나은 대안 제시. 가급적 반영 권장.
P3: 제안 (Suggestion) - 아이디어 공유. 반영 여부는 드라이버 자율.
P4: 단순 확인/칭찬 (Nit) - 사소한 오타, 칭찬 등 피드백.

Summary by CodeRabbit

릴리스 노트

  • 버그 수정

    • 네트워크 재시도 정책을 개선하여 서버 오류에만 재시도하고 클라이언트 오류는 즉시 실패 처리하도록 조정
    • 작업공간 및 캠페인 관리 작업 완료 시 데이터 동기화를 더욱 안정적으로 처리
  • 개선 사항

    • UI 업데이트가 서버 데이터 동기화 완료 후 진행되어 데이터 일관성 강화

axiosInstance 인터셉터가 401 재발급을 별도로 처리하므로
전역 retry: 1이 4xx 에러에서 불필요한 중복 재시도를 유발하는 문제를 수정
백그라운드 갱신 의도를 void로 명시해 암묵적 Promise 무시 패턴 제거
setIsOpen(false)가 await Promise.all 이전에 실행되어
드롭다운이 캐시 갱신 전에 닫히던 문제를 수정
Workspace.tsx: 워크스페이스 생성 후 setCreateOpen(false) 이전에 캐시 갱신 완료 보장
MemberManagement.tsx: 멤버 삭제 후 setIsDeleteModalOpen(false) 이전에 캐시 갱신 완료 보장
@Seojegyeong Seojegyeong self-assigned this Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 80015eef-aca3-42a5-9296-31fd6a3b6103

📥 Commits

Reviewing files that changed from the base of the PR and between 8f0e53a and 38b9718.

📒 Files selected for processing (6)
  • src/components/sidebar/WorkspaceSwitcher.tsx
  • src/hooks/ads/useCampaignGroup.ts
  • src/lib/queryClient.ts
  • src/pages/ads/list/AdsListPage.tsx
  • src/pages/workspace/MemberManagement.tsx
  • src/pages/workspace/Workspace.tsx

📝 Walkthrough

Walkthrough

queryClient에 HTTP 상태 코드 기반 retryPolicy 함수를 도입해 4xx는 재시도하지 않고 5xx는 1회만 재시도하도록 변경했습니다. 아울러 여러 mutation onSuccess 콜백에서 invalidateQueries 호출을 await로 완료를 기다리거나 void로 명시적으로 무시하는 방식으로 비동기 처리를 정비했습니다.

Changes

쿼리 클라이언트 재시도 정책 및 무효화 흐름 정비

Layer / File(s) Summary
queryClient 재시도 정책 함수 도입
src/lib/queryClient.ts
retryPolicy 함수를 추가해 IApiErrorResponse.status 기준으로 4xx는 즉시 실패, 5xx는 failureCount < 1인 경우에만 1회 재시도하도록 하며, retry 옵션을 고정 숫자(1)에서 해당 함수로 교체했습니다.
onSuccess에서 invalidateQueries await 처리
src/components/sidebar/WorkspaceSwitcher.tsx, src/pages/workspace/MemberManagement.tsx, src/pages/workspace/Workspace.tsx
WorkspaceSwitchersetIsOpen(false) 호출을 Promise.all 완료 이후로 이동하고, MemberManagementWorkspaceonSuccessasync로 전환해 invalidateQueriesawait로 대기하도록 변경했습니다.
fire-and-forget invalidateQueries void 처리
src/hooks/ads/useCampaignGroup.ts, src/pages/ads/list/AdsListPage.tsx
invalidateQueries 호출 결과를 void로 명시적으로 무시하도록 변경했습니다.

예상 코드 리뷰 노력

🎯 2 (Simple) | ⏱️ ~10 minutes

관련 가능성이 있는 PR

  • WhereYouAd/WhereYouAd-Frontend#75: Workspace.tsxcreateWorkspace onSuccess 흐름에서 invalidateQueries 처리 및 모달 닫기 로직이 직접적으로 맞물립니다.
  • WhereYouAd/WhereYouAd-Frontend#248: WorkspaceSwitcher, AdsListPage, MemberManagement, Workspace 등 동일 파일들의 invalidateQueries 쿼리 키를 QUERY_KEYS로 중앙화하는 변경으로, 이번 PR의 수정 대상과 직접 겹칩니다.
  • WhereYouAd/WhereYouAd-Frontend#138: MemberManagement.tsxdeleteMemberMutation onSuccess에서 쿼리 무효화 연동 방식을 다룬 변경으로 코드 레벨에서 직접 맞물립니다.

제안 레이블

🔨 Refactor

제안 리뷰어

  • YermIm
  • jjjsun
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 PR의 주요 변경사항(retry 전략 세분화, invalidateQueries 통일)을 명확하고 구체적으로 요약하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 모든 필수 섹션을 포함하고 있으며, 변경사항과 작업 내용이 구체적이고 명확합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/#241

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📚 Storybook 배포 완료

항목 링크
📖 Storybook https://69a147b60a56365d9e2185ef-fwjfwrnaqa.chromatic.com/
🔍 Chromatic https://www.chromatic.com/build?appId=69a147b60a56365d9e2185ef&number=348

@Seojegyeong
Seojegyeong requested review from YermIm and jjjsun June 23, 2026 13:46

@jjjsun jjjsun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4: 확인헀습니다!

@Seojegyeong
Seojegyeong merged commit 8896a8e into develop Jun 23, 2026
3 checks passed
@Seojegyeong
Seojegyeong deleted the refactor/#241 branch June 23, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

♻️ [Refactor] invalidateQueries 처리 기준 통일 및 retry 전략 세분화

2 participants