Skip to content

Conversation

six-standard
Copy link
Member

@six-standard six-standard commented Mar 8, 2025

릴리즈 브랜치를 생성하였습니다.
dev에서 PR들을 받아오고, 이 브랜치에서 main 브랜치로 머지합니다

Summary by CodeRabbit

  • New Features
    • 사용자에게 친숙한 에러 페이지가 새로 추가되어, 오류 발생 시 반응형 디자인과 명확한 안내 메시지를 제공합니다.
  • Bug Fixes
    • 비인가 접근 시 올바른 오류 처리를 적용해, 사용자 리디렉션 및 안내가 개선되었습니다.
  • Refactor
    • 로그아웃 및 세션 갱신 과정이 최적화되어, 보다 일관된 사용자 경험을 제공합니다.
    • 사용자 이름 및 URL 접근 방식이 간소화되었습니다.

* modify: 캐시 충돌 관련 이슈 해결

* modify: 로그아웃 시에도 캐시 잔존 오류 해결

* modify: 사소한 휴먼에러 해결

* refactor: 필요없는 주석 제거
* modify: 캐시 충돌 관련 이슈 해결

* modify: 로그아웃 시에도 캐시 잔존 오류 해결

* modify: 사소한 휴먼에러 해결

* refactor: 필요없는 주석 제거

* feature: 서버 에러 핸들링 페이지 퍼블리싱

* feature: 순수 HTML 형태의 오류 페이지 제작

* modify: 빌드 오류 수정

* modify: 리뷰 반영

* refactor: 파일명 변경
Copy link

Copy link

Copy link

coderabbitai bot commented Mar 8, 2025

Walkthrough

이번 PR은 Velog Dashboard의 오류 처리 및 사용자 인터페이스를 개선하는 변경 사항을 포함합니다. 새로운 HTML 에러 페이지(500.html)가 추가되어 오류 상황에서 사용자에게 적절한 안내를 제공하며, Sentry 의존성이 도입되어 오류 추적 기능이 강화되었습니다. 또한, HTTP 상태 코드 조건 수정, 캐시 클리어 로직 제거, 재검증(revalidate) 호출 추가 등 여러 컴포넌트에서 상태 및 캐시 관리 로직이 변경되었습니다. GC_TIME 상수 값 조정과 함께, 사용자 프로필 관련 코드 단순화도 이루어졌습니다.

Changes

파일 변경 요약
500.html, src/utils/revalidateUtil.ts 새로운 HTML 에러 페이지 추가 및 비동기 revalidate 함수(revalidate()) 신규 도입
package.json "@sentry/core": "^8.47.0" 의존성 추가
src/apis/instance.request.ts 오류 처리 조건 변경: 기존 403 → 401 상태 코드 확인
src/app/(with-tracker)/.../Content.tsx useQueryClientclient.clear() 제거, 로그인 성공 시 캐시 클리어 로직 삭제
src/components/auth-required/header/index.tsx 로그아웃 시, 기존 client.removeQueries() 호출 대신 비동기 revalidate() 호출 추가 및 useQuery 옵션 변경
src/components/auth-required/main/Section/index.tsx useQueryClient 제거, 대신 getQueryClient() 사용 및 username 관련 로직 단순화, URL 구성 간소화
src/utils/queryUtil.ts GC_TIME 값 1000 (1초)에서 1000 * 60 * 20 (20분)으로 변경

Sequence Diagram(s)

sequenceDiagram
  participant 사용자
  participant 헤더컴포넌트
  participant revalidate()
  participant 캐시 as next/cache
  participant 라우터 as next/navigation

  사용자->>헤더컴포넌트: 로그아웃 요청
  헤더컴포넌트->>revalidate(): revalidate() 호출
  revalidate()->>캐시: revalidatePath("/") 호출
  캐시-->>revalidate(): 경로 재검증 완료
  revalidate()->>라우터: redirect("/") 호출
  라우터-->>revalidate(): 리다이렉션 완료
  헤더컴포넌트->>헤더컴포넌트: 캐시 클리어 및 UI 업데이트
Loading

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • Nuung
  • HA0N1

Poem

나는 귀여운 토끼, 코드 숲을 누비네
500.html의 빛 아래 오류도 노래하네
revalidate의 마법으로 길을 열고
상태와 캐시, 깔끔하게 정리되었네
hop hop 뛰며 새 변화에 춤추는 나, 코딩 세상 화이팅! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a02bf2 and f38f3dc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/utils/revalidateUtil.ts (1)

6-9: 재검증과 리다이렉트 로직의 분리를 고려해보세요

현재 revalidate 함수는 재검증과 리다이렉트를 동시에 수행합니다. 이 두 가지 기능을 하나의 함수에 결합하면 유연성이 제한될 수 있습니다. 재검증만 필요하거나 다른 경로로 리다이렉트해야 하는 상황에서는 현재 함수를 재사용하기 어렵습니다.

다음과 같이 분리하는 것을 고려해보세요:

'use server';

import { revalidatePath } from 'next/cache';
import { redirect } from 'next/navigation';

-export async function revalidate() {
-  revalidatePath('/', 'layout');
-  redirect('/');
-}
+export async function revalidateSite() {
+  revalidatePath('/', 'layout');
+}
+
+export async function revalidateAndRedirect(path = '/') {
+  revalidatePath('/', 'layout');
+  redirect(path);
+}
src/components/auth-required/header/index.tsx (1)

42-46: 로그아웃 로직 개선 및 client.clear() 사용 검토 필요

로그아웃 시 revalidate()를 호출하여 캐시를 재검증하는 방식으로 변경한 것은 적절합니다. 하지만 client.clear()는 모든 쿼리 캐시를 지우는 강력한 방법으로, 필요한 다른 데이터까지 삭제될 수 있습니다.

더 선택적인 접근 방식을 고려해보세요:

onSuccess: async () => {
  await revalidate();
-  client.clear();
+  client.removeQueries({ queryKey: [PATHS.ME] });
+  // 필요한 경우 다른 인증 관련 쿼리도 제거
  router.replace('/');
},
500.html (2)

141-153: 전역 스타일 개선 제안

전역 스타일 설정에서 개선이 가능한 부분이 있습니다:

  * {
    transition: all;
    transition-duration: 300ms;
+   margin: 0;
+   padding: 0;
+   box-sizing: border-box;
  }
  body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #121212;
    display: flex;
    align-items: center;
    justify-content: center;
+   font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  }

폰트 패밀리를 지정하고 margin, padding 초기화를 추가하면 더 일관된 디자인이 될 것입니다.


164-164: 오류 메시지 개선 제안

현재 오류 메시지는 "알 수 없는 오류가 발생했습니다."로 설정되어 있습니다. 사용자에게 더 명확한 정보와 행동 지침을 제공하는 것이 좋습니다.

- <span class="text">알 수 없는 오류가 발생했습니다.</span>
+ <span class="text">알 수 없는 오류가 발생했습니다.</span>
+ <span class="text" style="font-size: smaller; margin-top: 10px;">잠시 후 다시 시도하거나, 문제가 지속되면 관리자에게 문의해주세요.</span>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a45831 and 6a02bf2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • 500.html (1 hunks)
  • package.json (1 hunks)
  • src/apis/instance.request.ts (1 hunks)
  • src/app/(with-tracker)/(login)/Content.tsx (1 hunks)
  • src/components/auth-required/header/index.tsx (2 hunks)
  • src/components/auth-required/main/Section/index.tsx (1 hunks)
  • src/utils/queryUtil.ts (1 hunks)
  • src/utils/revalidateUtil.ts (1 hunks)
🔇 Additional comments (9)
src/utils/queryUtil.ts (1)

6-6: GC_TIME 값 증가 변경 - 적절한 최적화입니다

GC_TIME을 1초에서 20분(1000 * 60 * 20)으로 변경한 것은 적절한 최적화입니다. 기존 1초는 매우 짧은 시간으로, 쿼리 데이터가 비활성화되자마자 거의 즉시 가비지 컬렉션 대상이 되어 성능 저하를 일으킬 수 있었습니다.

20분으로 늘림으로써 사용자가 다른 페이지에 갔다가 돌아오더라도 이미 가져온 데이터를 재사용할 수 있어 불필요한 API 호출을 줄이고 애플리케이션 성능을 향상시킬 수 있습니다.

src/components/auth-required/header/index.tsx (2)

12-12: revalidate 유틸리티 함수 추가 - 적절합니다

revalidate 함수를 가져와서 사용하는 것은 로그아웃 시 캐시 무효화를 위한 좋은 접근법입니다.


52-54: enabled 조건 추가 - 적절한 최적화입니다

쿼리에 enabled: !!client.getQueryData([PATHS.ME]) 조건을 추가한 것은 매우 적절합니다. 이 변경으로 로그아웃 후 불필요한 API 호출을 방지하여 성능을 개선하고, 로그아웃 후 재로그인 전까지 불필요한 오류를 방지할 수 있습니다.

주석에서 설명한 대로 prefetch를 통해 이미 데이터가 로드된 상태이므로 캐시 여부만 확인하는 접근은 합리적입니다.

src/apis/instance.request.ts (1)

78-78: 인증 상태 코드 처리 변경이 적절합니다.

인증되지 않은 요청에 대한 처리가 HTTP 상태 코드 403에서 401로 변경되었습니다. 이는 HTTP 표준에 더 적합한 변경으로, 401은 인증 부재(미로그인)를, 403은 권한 부족(로그인했으나 권한 없음)을 의미합니다.

src/app/(with-tracker)/(login)/Content.tsx (2)

24-27: 로그인 성공 후 캐시 관리 로직이 간소화되었습니다.

이전에는 로그인 성공 시 쿼리 캐시를 초기화했지만, 지금은 해당 로직이 제거되었습니다. 이로 인해 이전 세션의 캐시된 데이터가 새 세션에 영향을 미칠 가능성이 있습니다.

이 변경이 의도적인 것인지, 그리고 프로젝트에서 다른 방식으로 쿼리 캐시를 관리하고 있는지 확인하세요.


6-6:

❓ Verification inconclusive

캐시 클리어 로직이 제거되었습니다.

useQueryClient 및 client.clear() 호출이 제거되었습니다. 이 변경으로 로그인 후 쿼리 캐시가 더 이상 초기화되지 않습니다.

이 변경이 의도적인 것인지, 그리고 애플리케이션의 다른 부분에서 캐시를 관리하는 대체 메커니즘이 있는지 확인해 주세요. 로그인 시 캐시를 초기화하지 않으면 이전 세션의 데이터가 남아있을 수 있습니다.


🏁 Script executed:

#!/bin/bash
# Description: 캐시 관리 패턴 확인하기

# revalidateUtil.ts 파일이 있는지 확인
echo "=== revalidateUtil.ts 파일 찾기 ==="
fd revalidateUtil.ts

# revalidate 함수가 있는 위치 확인
echo "=== revalidate 함수 찾기 ==="
rg "export const revalidate" -A 5

# 쿼리 클라이언트 초기화/관리 패턴 찾기
echo "=== 쿼리 클라이언트 초기화 패턴 확인 ==="
rg "getQueryClient\(\)\.clear\(\)" -A 2 -B 2

Length of output: 328


로그인 캐시 초기화 로직 변경 확인 요청

현재 PR에서 src/app/(with-tracker)/(login)/Content.tsx 파일에서 기존의 useQueryClientclient.clear() 호출이 제거된 것을 확인했습니다.
또한, src/utils/revalidateUtil.ts 파일이 존재하는 점으로 미루어 보아, 캐시 관리가 다른 방식으로 대체되었을 가능성이 있습니다. 다만,

  • export const revalidate 관련 코드를 검색했을 때 명시적으로 캐시 초기화를 수행하는 로직이 나타나지 않았습니다.
  • getQueryClient().clear() 호출도 전체 코드베이스에서 찾을 수 없었습니다.

이에 따라, 해당 변경이 의도된 것인지, 그리고 다른 부분에서 캐시 초기화를 위한 대체 메커니즘(예: revalidateUtil.ts 내에서 수행하는 로직 등)이 충분히 구현되어 있는지 수동으로 재검증해 주시기 바랍니다. 만약 다른 캐시 관리 체계가 존재한다면, 관련 설명이나 문서 업데이트도 함께 제공해 주시면 좋겠습니다.

src/components/auth-required/main/Section/index.tsx (2)

9-9: 쿼리 클라이언트 접근 방식 변경

useQueryClient 훅 대신 getQueryClient 유틸리티 함수를 사용하도록 변경되었습니다. 이는 전체 애플리케이션에서 쿼리 클라이언트 접근 방식을 표준화하기 위한 변경으로 보입니다.


19-19: URL 생성 로직 간소화

URL 생성 로직이 간소화되었습니다. 이전에는 별도의 URL 변수를 사용했지만, 지금은 env.VELOG_URL을 직접 사용합니다.

500.html (1)

1-180: 적절한 서버 오류 페이지 추가

서버 오류 발생 시 표시될 500 에러 페이지가 추가되었습니다. 페이지는 다양한 화면 크기에 대응하는 반응형 디자인으로 구현되었으며, 사용자에게 오류 발생을 명확히 알리고 있습니다.

분석 추적을 위한 Google 태그 관리자 스크립트도 포함되어 있어 오류 발생 빈도를 모니터링할 수 있습니다.

@six-standard six-standard self-assigned this Mar 8, 2025
@six-standard six-standard added the enhancement New feature or request label Mar 8, 2025
@six-standard six-standard merged commit 60486b0 into main Mar 8, 2025
1 check passed
@six-standard six-standard deleted the release branch March 9, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant