Skip to content

fix: useStomp.ts에서 WebSocket 닫힘 이벤트 로깅 추가 및 ChatApplyPage.tsx에서 요청 목록…#50

Merged
koreahghg merged 2 commits intomainfrom
fix/mentoring
Dec 29, 2025
Merged

fix: useStomp.ts에서 WebSocket 닫힘 이벤트 로깅 추가 및 ChatApplyPage.tsx에서 요청 목록…#50
koreahghg merged 2 commits intomainfrom
fix/mentoring

Conversation

@koreahghg
Copy link
Collaborator

… 가져오기 로직 개선

💡 배경 및 개요

PR을 하게 된 문제상황, 배경 및 개요에 대해서 작성해주세요!

퍼블리싱의 경우 스크린샷/동영상도 추가해주면 좋아요!

Resolves: #{이슈번호}

📃 작업내용

PR에서 한 작업을 작성해주세요!

🙋‍♂️ 리뷰노트

구현 시에 고민이었던 점들 혹은 특정 부분에 대한 의도가 있었다면 PR 리뷰의 이해를 돕기 위해 서술해주세요!

또한 리뷰어에게 특정 부분에 대한 집중 혹은 코멘트 혹은 질문을 요청하는 경우에 작성하면 좋아요!

e.g. 작업을 끝내야할 시간이 얼마 없어 확장성보다는 동작을 위주로 만들었어요! 감안하고 리뷰해주세요!

✅ PR 체크리스트

템플릿 체크리스트 말고도 추가적으로 필요한 체크리스트는 추가해주세요!

  • 이 작업으로 인해 변경이 필요한 문서가 변경되었나요? (e.g. .env, 노션, README)
  • 이 작업을 하고나서 공유해야할 팀원들에게 공유되었나요? (e.g. "API 개발 완료됐어요", "환경값 추가되었어요")
  • 작업한 코드가 정상적으로 동작하나요?
  • Merge 대상 브랜치가 올바른가요?
  • PR과 관련 없는 작업이 있지는 않나요?

🎸 기타

@vercel
Copy link

vercel bot commented Dec 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
cklob-gami Ready Ready Preview, Comment Dec 29, 2025 2:34pm

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @koreahghg, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 채팅 신청 요청과 관련된 실시간 업데이트의 안정성과 사용자 경험을 향상시키는 데 중점을 둡니다. useStomp.ts 파일에서는 WebSocket 연결 종료 시 디버깅을 위한 상세 로깅을 추가했습니다. ChatApplyPage.tsx에서는 기존의 useStomp 기반 알림 로직을 제거하고, 10초 간격으로 서버에서 받은 요청 목록을 주기적으로 가져와 새로운 요청이 있을 경우 사용자에게 토스트 알림을 제공하는 폴링 방식으로 변경했습니다. 이는 특정 기능에 대한 실시간 업데이트 방식을 재조정하여 안정성을 높이고, useCallback을 활용해 성능을 최적화한 것입니다.

Highlights

  • useStomp.ts WebSocket 닫힘 이벤트 로깅 강화: WebSocket 닫힘 이벤트 발생 시 codereason을 포함한 상세한 정보를 로깅하도록 개선하여 디버깅 용이성을 높였습니다.
  • ChatApplyPage.tsx 요청 목록 가져오기 로직 개선: useStomp를 통한 실시간 알림 대신, setInterval을 사용하여 10초마다 받은 요청 목록을 폴링 방식으로 업데이트하도록 변경했습니다. 새로운 보류 중인 요청이 감지될 경우, 토스트 알림을 통해 사용자에게 즉시 알리는 기능을 추가했으며, fetchReceivedRequestsfetchSentRequests 함수를 useCallback으로 래핑하여 성능 최적화를 도모했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@koreahghg koreahghg merged commit 4f98993 into main Dec 29, 2025
3 checks passed
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이번 PR은 useStomp.ts에 WebSocket 연결 종료 이벤트 로깅을 추가하고, ChatApplyPage.tsx에서 멘토링 요청 목록을 가져오는 로직을 개선했습니다.

useStomp 훅에 상세한 로깅을 추가한 것은 디버깅에 큰 도움이 될 좋은 변경입니다.

ChatApplyPage에서는 기존의 WebSocket 기반 실시간 알림을 10초 주기의 폴링 방식으로 변경하셨습니다. 이는 WebSocket 연결의 불안정성 문제를 해결하기 위한 것일 수 있으나, 실시간성이 저하되고 주기적인 API 호출로 서버 부하가 증가할 수 있는 트레이드오프가 있습니다. 이 설계 변경에 대한 배경을 공유해주시면 리뷰에 더 도움이 될 것 같습니다.

폴링 로직 구현과 관련하여, 알림 메시지 생성 시 발생할 수 있는 잠재적 버그와 코드 효율성을 개선할 수 있는 부분에 대해 몇 가지 리뷰 의견을 남겼습니다. useCallback을 사용하여 함수를 메모이제이션한 것은 좋은 접근입니다. 전반적으로 코드 품질을 높이기 위한 좋은 시도라고 생각합니다.

Comment on lines +37 to +52
const newCount = response.data.filter(
(req) => req.applyStatus === 'PENDING'
).length;

// 새로운 요청이 들어온 경우 알림
if (newCount > previousReceivedCountRef.current) {
const newRequests = response.data.filter(
(req) => req.applyStatus === 'PENDING'
);
const addedCount = newCount - previousReceivedCountRef.current;
if (addedCount === 1 && newRequests.length > 0) {
toast.info(`${newRequests[0].name}님한테 요청이 왔어요`);
} else if (addedCount > 1) {
toast.info(`${addedCount}개의 새로운 요청이 왔어요`);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

멘토링 요청 알림 로직에 두 가지 개선점을 제안합니다.

  1. 비효율적인 필터링: response.data에 대해 filter 연산을 두 번 수행하고 있습니다. 한 번의 필터링으로 pendingRequests를 구하고, 그 결과를 재사용하여 성능을 개선할 수 있습니다.

  2. 잠재적 버그: addedCount === 1일 때 newRequests[0].name을 사용하여 알림을 표시하는 로직은 API 응답이 항상 최신순으로 정렬되어 있다는 가정에 의존합니다. 만약 정렬 순서가 보장되지 않으면, 새로 도착한 요청이 아닌 다른 요청자의 이름이 표시될 수 있어 사용자에게 혼란을 줄 수 있습니다.

가장 간단하고 안전한 해결책은 요청자 이름을 표시하는 대신, 새로 도착한 요청의 수만 알려주는 것입니다. 아래와 같이 수정하면 두 문제를 모두 해결할 수 있습니다.

        const pendingRequests = response.data.filter(
          (req) => req.applyStatus === 'PENDING'
        );
        const newCount = pendingRequests.length;

        // 새로운 요청이 들어온 경우 알림
        if (newCount > previousReceivedCountRef.current) {
          const addedCount = newCount - previousReceivedCountRef.current;
          toast.info(`새로운 요청이 ${addedCount}개 도착했어요`);
        }

// 10초마다 받은 요청 확인
const pollInterval = setInterval(() => {
fetchReceivedRequests();
}, 10000);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

폴링 간격으로 사용된 10000은 '매직 넘버'입니다. 코드의 가독성과 유지보수성을 높이기 위해, 이 값을 컴포넌트 상단에 의미 있는 이름의 상수로 정의하는 것이 좋습니다.

const POLLING_INTERVAL_MS = 10000;

// ...

useEffect(() => {
  // ...
  const pollInterval = setInterval(() => {
    fetchReceivedRequests();
  }, POLLING_INTERVAL_MS);
  // ...
});

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.

2 participants