Skip to content

fix: replace panic("unreachable") with descriptive error in SSE handler#21

Merged
changkun merged 1 commit into
mainfrom
changkun/fix-sse-panic
Apr 10, 2026
Merged

fix: replace panic("unreachable") with descriptive error in SSE handler#21
changkun merged 1 commit into
mainfrom
changkun/fix-sse-panic

Conversation

@changkun

Copy link
Copy Markdown
Collaborator

Summary

  • Replace panic("unreachable") at the end of handleSSEResponse with a proper error return
  • The SSE event loop can exit without a terminal event (parse_done/parse_failed) when the server disconnects prematurely — this was causing a crash in callers
  • The error now reports whether zero events were received (immediate disconnect) or partial events with the last event name seen, making it easier to diagnose the root cause

The SSE event loop in handleSSEResponse could exit without hitting a
terminal event (parse_done or parse_failed) when the server disconnects
prematurely. This was guarded by panic("unreachable") which crashed the
caller. Return a descriptive error instead, reporting whether zero or
partial events were received and the last event name seen.
@changkun changkun merged commit 0465e5a into main Apr 10, 2026
4 checks passed
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.

1 participant