Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughuseLogout 성공 핸들러에 userInfo 쿼리 무효화가 추가되었습니다. 이를 위해 shared의 userQueryKeys가 export되어 외부에서 참조 가능해졌습니다. 그 외 공개 API 시그니처 변화는 userQueryKeys의 export 추가뿐입니다. Changes
Sequence Diagram(s)sequenceDiagram
actor U as User
participant C as Component/useLogout
participant S as Logout API
participant Q as QueryClient
U->>C: Trigger logout()
C->>S: call logout mutation
S-->>C: onSuccess
rect rgba(200,235,255,0.3)
note right of C: 변경됨
C->>Q: clear()
C->>Q: invalidateQueries({ queryKey: userQueryKeys.userInfo() })
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
This pull request (commit
|
🚀 Storybook 배포📖 Storybook: https://683d91ab23651aa0b399e435-jzdsemfqcd.chromatic.com/ |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
shared/api/queries/user.ts (1)
6-9: userQueryKeys export은 적절합니다. 반환 키를 튜플로 고정해 타입 안정성 강화 제안현재
as const는 객체 프로퍼티에만 영향을 주고, 함수 반환값 배열은 여전히string[]로 추론됩니다. React Query v5의QueryKey(readonly unknown[])와도 호환되지만, 키 타이핑을 더 견고하게 만들기 위해 반환 배열도 튜플로 고정하는 것을 권장합니다. 향후 키 변경 시 컴파일 타임에서 더 빨리 깨집니다.export const userQueryKeys = { - all: () => ["user"], - userInfo: () => [...userQueryKeys.all(), "userInfo"], + all: () => ["user"] as const, + userInfo: () => [...userQueryKeys.all(), "userInfo"] as const, } as const; +export type UserQueryKey = ReturnType<typeof userQueryKeys.userInfo>;app/(auth)/_api/auth.queries.ts (2)
21-22: clear 이후 invalidate는 실익이 없습니다
clear()로 캐시를 지운 직후 동일 키를invalidate해도 타겟 쿼리가 없어 no-op에 가깝습니다. 위 코멘트대로 취소/제거로 대체하거나,clear()만 쓰는 전략으로 단순화하세요.
22-22: 특정 키보다 루트 키로 범위 지정 권장확장성을 위해
userInfo()가 아닌userQueryKeys.all()기준으로 무효화/제거/취소를 수행하면 향후user하위 키가 늘어나도 변경이 최소화됩니다.- queryClient.invalidateQueries({ queryKey: userQueryKeys.userInfo() }); + queryClient.invalidateQueries({ queryKey: userQueryKeys.all() });
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
app/(auth)/_api/auth.queries.ts(2 hunks)shared/api/queries/user.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/(auth)/_api/auth.queries.ts (1)
shared/api/queries/user.ts (1)
userQueryKeys(6-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: storybook-deploy
- GitHub Check: test
- GitHub Check: deploy
| onSuccess: () => { | ||
| queryClient.clear(); | ||
| queryClient.invalidateQueries({ queryKey: userQueryKeys.userInfo() }); | ||
| }, |
There was a problem hiding this comment.
로그아웃 시 in-flight 쿼리 취소 없이 clear만 수행 → 레이스로 인해 사용자 정보가 다시 캐시에 등장할 수 있습니다
queryClient.clear()는 진행 중인 fetch를 취소하지 않습니다. 로그아웃 직전 발행된 userInfo 요청이 응답되면, 캐시가 다시 채워져 PII가 UI에 잠깐 노출될 수 있습니다. 먼저 관련 쿼리를 취소하고 제거하는 순서로 바꾸는 것을 권장합니다. 이 경우 invalidateQueries는 불필요합니다.
- return useMutation({
+ return useMutation({
mutationFn: postLogout,
- onSuccess: () => {
- queryClient.clear();
- queryClient.invalidateQueries({ queryKey: userQueryKeys.userInfo() });
- },
+ onSuccess: async () => {
+ // 1) 사용자 관련 쿼리 먼저 취소하여 레이스 방지
+ await queryClient.cancelQueries({ queryKey: userQueryKeys.all() });
+ // 2) 사용자 관련 캐시 제거
+ queryClient.removeQueries({ queryKey: userQueryKeys.all() });
+ // 3) (선택) 전역 캐시까지 비우고 싶다면 아래를 사용하되, 퍼블릭 데이터까지 지워지는 점 유의
+ // queryClient.clear();
+ },
});📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onSuccess: () => { | |
| queryClient.clear(); | |
| queryClient.invalidateQueries({ queryKey: userQueryKeys.userInfo() }); | |
| }, | |
| return useMutation({ | |
| mutationFn: postLogout, | |
| onSuccess: async () => { | |
| // 1) 사용자 관련 쿼리 먼저 취소하여 레이스 방지 | |
| await queryClient.cancelQueries({ queryKey: userQueryKeys.all() }); | |
| // 2) 사용자 관련 캐시 제거 | |
| queryClient.removeQueries({ queryKey: userQueryKeys.all() }); | |
| // 3) (선택) 전역 캐시까지 비우고 싶다면 아래를 사용하되, 퍼블릭 데이터까지 지워지는 점 유의 | |
| // queryClient.clear(); | |
| }, | |
| }); |
🤖 Prompt for AI Agents
In app/(auth)/_api/auth.queries.ts around lines 20 to 23, the logout handler
currently calls queryClient.clear() and invalidateQueries, which doesn't cancel
in-flight fetches and can let a pending userInfo response repopulate the cache;
instead, first call await queryClient.cancelQueries({ queryKey:
userQueryKeys.userInfo() }) to stop any ongoing fetch, then call
queryClient.removeQueries({ queryKey: userQueryKeys.userInfo(), exact: true })
to remove the cached entry; drop the invalidateQueries call (and avoid clear()
unless you also cancel all queries first) so the userInfo cannot reappear after
logout.
📌 Summary
해당 PR에 대한 작업 내용을 요약하여 작성해주세요.
📚 Tasks
로그아웃시 로그인 페이지로 바로 이동하도록 수정합니다.
Summary by CodeRabbit