feat!: report every SSE error response with status, headers, and recoverability#311
Open
kinyoklion wants to merge 1 commit into
Open
Conversation
306fef8 to
2343975
Compare
…verability Replace UnrecoverableStatusError with SseHttpError, reported on the event stream for any non-200 response -- recoverable or not. It carries the status code, the response headers (which may hold a service directive), and a recoverable flag indicating whether the client will retry on its own (backoff) or has stopped. BREAKING CHANGE: The SSE client now reports recoverable error responses (e.g. 5xx) on the stream; previously only unrecoverable responses surfaced and recoverable ones were retried silently. A consumer that treats any error from the stream as terminal will now tear down on a transient error. Such consumers must check SseHttpError.recoverable and ignore recoverable errors -- the client retries those on its own. UnrecoverableStatusError is removed; use SseHttpError (statusCode, headers, recoverable) instead.
2343975 to
6bcf11f
Compare
joker23
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⚠ Breaking change
The SSE client now reports recoverable error responses (e.g. 5xx) on the stream. Previously only unrecoverable responses surfaced and recoverable ones were retried silently. A consumer that treats any error from the stream as terminal will now tear down on a transient error — it must check
SseHttpError.recoverableand ignore recoverable errors (the client retries those itself).UnrecoverableStatusErroris removed; useSseHttpErrorinstead.This bumps event_source to a major (2.2.0 → 3.0.0).
What
Replaces
UnrecoverableStatusErrorwithSseHttpError, reported on the event stream for any non-200 response — recoverable or not. It carries:statusCodeheaders(always — may hold a service directive)recoverable— whether the client will retry on its own (backoff) or has stoppedWhy
A LaunchDarkly streaming endpoint can deliver the FDv2-to-FDv1 fallback directive (
x-ld-fd-fallback) in the headers of an otherwise-retriable error response (e.g. a 500). Previously recoverable responses surfaced nothing, so that directive was invisible and the client just kept reconnecting. Now every error response is reported with its headers and arecoverableflag, and the consumer decides what to do. This keeps the client a pure transport — it reports what it saw rather than taking an injected retry policy. The browserEventSourcecannot observe responses and reports nothing, as before.Tests
state_connectingcovers a recoverable error (backs off, reportsrecoverable: truewith headers) and an unrecoverable one (goes idle, reportsrecoverable: falsewith headers).First of a two-PR stack; the fallback behavior that consumes this is in the stacked follow-up.
Note
Medium Risk
Breaking public API rename and new stream errors on recoverable HTTP failures may affect consumers that only handled unrecoverable cases; reconnect behavior is unchanged but observability of errors increases.
Overview
Breaking: Replaces exported
UnrecoverableStatusErrorwithSseHttpError, which includesstatusCode,headers, and a requiredrecoverableflag.Behavior: On any non-200 HTTP response during connect, the client now surfaces
SseHttpErroron the event stream—not only when retries stop. For recoverable statuses it still backs off and reconnects, but first emits the error (so headers likex-ld-fd-fallbackare visible on retriable failures). For non-recoverable statuses it still transitions to idle and reports the same error type withrecoverable: false.Tests were updated to assert stream errors for both recoverable (e.g. 503) and unrecoverable (e.g. 401) cases, including directive headers.
Reviewed by Cursor Bugbot for commit 6bcf11f. Bugbot is set up for automated code reviews on this repo. Configure here.