Skip to content

fix(execution): 시작된 SSE 응답의 예외 처리와 유휴 연결 하트비트 (#153) - #154

Merged
exijn merged 1 commit into
developfrom
fix/153-sse-closed-stream-error-and-heartbeat
Nov 11, 2026
Merged

exijn merged 1 commit into
developfrom
fix/153-sse-closed-stream-error-and-heartbeat

Conversation

@exijn

@exijn exijn commented Nov 11, 2026

Copy link
Copy Markdown
Member

관련 Issue

Closes #153

작업 배경

시연 중 Server 로그에 HttpMessageNotWritableException: No converter for ApiResponse with preset Content-Type 'text/event-stream' WARN 이 쌓이고(오늘 98건), Client 에는 Failed to proxy …/events socket hang up 가 쌓였다(351줄). 같은 사건의 양쪽이다. 원인은 이슈 #153 에 코드 근거와 함께 적었다.

변경 사항

  • GlobalExceptionHandler.handleException: 응답 Content-Type 이 이미 text/event-stream 이면 JSON 본문을 쓰지 않고 null 을 돌려 처리를 끝낸다. 연결 끊김·만료(AsyncRequestTimeoutException, AsyncRequestNotUsableException, IOException)는 debug, 그 밖의 예외는 스택과 함께 warn. 시작 전 오류(401 등)와 일반 요청의 500 은 그대로 JSON.
  • ExecutionSseService.sendHeartbeat: 구독 중인 모든 SSE 연결에 :keepalive 주석 줄을 주기적으로 보낸다(기본 15초, poppy.execution.sse-heartbeat-milliseconds). Client(executionStream.ts)는 event:/data: 가 없는 프레임을 무시한다.

주요 설계 결정

  • 하트비트를 택한 이유: Next.js 재작성 프록시의 proxyTimeout 기본값이 30초(next@16.3.2)라 유휴 SSE 가 30초마다 끊긴다. Client 설정을 올리는 방법은 프록시 종류(Vercel 등)에 따라 안 먹을 수 있어, 프록시와 무관한 하트비트로 해결한다.
  • 테스트는 MockMvc 가 아니라 실제 내장 Tomcat 으로 한다. MockMvc 는 "커밋된 응답의 헤더 변경 무시"를 흉내 내지 못해 이 오류를 재현하지 못한다(시도해 확인).

검증 결과

  • 수정 전: SseStreamRealServerTest 의 만료·연결 끊김 2건이 Failure in @ExceptionHandler …handleException(Exception) WARN 으로 실패. 수정 후 통과.
  • ExecutionSseHeartbeatIntegrationTest: 이벤트 없는 구독에 :keepalive 가 오고 event:/data: 는 없음.
  • 전체 ./gradlew test 384건 통과, harness-check 통과.

영향 범위

GlobalExceptionHandler, ExecutionSseService. API 계약·이벤트 형식 변경 없음. 설정 키 1개 추가(선택, 기본 15000).

제외 범위

Client 의 proxyTimeout 설정 변경. 운영/시연 서비스 재시작(반영은 사람이 한다).

체크리스트

  • Issue 범위 준수
  • 관련 테스트 추가/수정
  • 전체 테스트 통과
  • 전체 빌드 통과
  • 비밀값 미포함
  • 문서 최신화 (해당 없음)
  • CLAUDE.md와 AGENTS.md 동일성 유지
  • 기존 사용자 변경사항 보존

🤖 Generated with Claude Code

SSE 응답은 시작할 때 Content-Type 이 text/event-stream 으로 굳는다. 그 뒤 만료·연결 끊김이 나면
공통 핸들러가 ApiResponse JSON 을 쓰려다 실패해 WARN 이 쌓였다. 시작된 SSE 응답에서는 본문을 쓰지 않는다.
이벤트가 없어도 구독 연결에 :keepalive 주석을 15초마다 보내 프록시(Next 기본 30초)의 유휴 종료를 막는다.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@exijn exijn added bug 버그 수정 작업 domain: execution execution 도메인 변경 labels Nov 11, 2026
@github-actions github-actions Bot added the test 테스트 관련 작업 label Nov 11, 2026
@exijn
exijn merged commit b921f4f into develop Nov 11, 2026
3 checks passed
@exijn
exijn deleted the fix/153-sse-closed-stream-error-and-heartbeat branch November 11, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 버그 수정 작업 domain: execution execution 도메인 변경 test 테스트 관련 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant