Skip to content

[FEAT] 에러 메시지 수신용 WebSocket 채널 구독 및 송신 실패 처리 로직 구현#1349

Merged
kimyou1102 merged 1 commit intodevelopfrom
feature/1347-add-error-websocket-channel
Mar 3, 2026
Merged

[FEAT] 에러 메시지 수신용 WebSocket 채널 구독 및 송신 실패 처리 로직 구현#1349
kimyou1102 merged 1 commit intodevelopfrom
feature/1347-add-error-websocket-channel

Conversation

@kimyou1102
Copy link
Contributor

Issue Number

closed #1347

As-Is

기존 구현에서는 채팅 전송 시 서버에서 비즈니스 로직 실패(예: 권한, 유효성, 상태 충돌 등)가 발생하더라도, 클라이언트가 이를 감지할 수 있는 STOMP 에러 구독 로직이 존재하지 않았습니다. 그 결과 아래와 같은 문제들이 있었습니다.

  • WebSocket 전송 자체는 성공했기 때문에 클라이언트는 성공으로 인식
  • 실제 서버 처리 실패와 UI 상태가 불일치하는 문제 발생
  • 사용자에게 전송 실패 피드백 제공 불가

즉, 전송 계층 성공과 비즈니스 로직 성공을 구분하지 못하는 구조였습니다.

To-Be

  • /user/queue/errors 경로를 구독하여 서버에서 전달되는 에러 메시지를 수신
  • 실패한 메시지를 tempId 기준으로 찾아 status: 'fail'로 업데이트
image

1. 에러 큐 구독 추가

client.subscribe('/user/queue/errors', ...)
  • 사용자 전용 에러 큐(/user/queue/errors)를 구독하도록 추가
  • 서버에서 전달한 에러 메시지를 수신

🔒 사용자 전용 큐 동작 방식

  • /user/queue/errors는 Spring의 @SendToUser(또는 convertAndSendToUser)를 통해 세션 단위로 라우팅되는 사용자 전용 큐입니다.
  • 따라서 클라이언트에서는 동일한 경로를 구독하더라도, 현재 연결된 세션에 해당하는 에러 메시지만 수신하게 됩니다.

2. tempId 기반 메시지 status 변경

if (message.tempId === parsedErrorMessage.tempId) {
  return { ...message, status: 'fail' };
}
  • tempId로 해당 메시지를 찾아 status: 'fail'로 업데이트
  • 낙관적 업데이트로 처리된 메시지를 실패 UI로 변경

Check List

  • 테스트가 전부 통과되었나요?
  • 모든 commit이 push 되었나요?
  • merge할 branch를 확인했나요?
  • Assignee를 지정했나요?
  • Label을 지정했나요?
  • 닫을 이슈 번호를 지정했나요?

(Optional) Additional Description

@kimyou1102 kimyou1102 requested a review from dlsxjzld February 22, 2026 10:25
@kimyou1102 kimyou1102 self-assigned this Feb 22, 2026
@kimyou1102 kimyou1102 added ❄️ FE 프론트엔드 ☘️ feat 기능 구현 labels Feb 22, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/1347-add-error-websocket-channel

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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 and usage tips.

Copy link
Contributor

@dlsxjzld dlsxjzld left a comment

Choose a reason for hiding this comment

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

실패하는 메시지는 개인만 알면 되기 때문에 따로 구독을 한 것 같은데 맞을까요? 🤔

이제 클라이언트에서도 실패한 메시지인지 알 수 있겠네요 👍
고생하셨습니다! 👍👍

@kimyou1102 kimyou1102 merged commit e7a15e2 into develop Mar 3, 2026
3 checks passed
@kimyou1102 kimyou1102 deleted the feature/1347-add-error-websocket-channel branch March 3, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

❄️ FE 프론트엔드 ☘️ feat 기능 구현

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEAT] 에러 메시지 수신용 웹소캣 채널 구독 추가

2 participants