Repository navigation
fix: fail the async SSE future when the stream errors - #599
Merged
Merged
Conversation
JavaClient.sse(request, handler) swallowed every failure with System.err.println and returned null, so a connection dropped mid-stream (or a failed connect) completed the CompletableFuture normally and callers could not tell the events had stopped. Let the exception propagate so the future completes exceptionally.
|
|
ryber
approved these changes
Nov 15, 2026
This was referenced Nov 17, 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.
UnirestInstance.sse(url).connect(handler)(async) returns aCompletableFuture<Void>, butJavaClient.sse(request, handler)ended with.exceptionally(ex -> { System.err.println(...); return null; }). Any failure (connect error, or the connection dropped mid-stream) was printed to stderr and the future completed normally, so callers could not distinguish "stream ended" from "stream broke".Fix: drop the swallowing
exceptionally, so the future completes exceptionally with the underlying error.Test:
SseStreamFailureTeststarts a local server that promises 1000 bytes, sends one event and hangs up. Before: the future completes normally. After:future.get()throwsExecutionException.Note: callers that relied on the future always succeeding will now see the failure; that seems to be the intent of returning a future.
This change was prepared with the assistance of an AI coding agent (Claude) and submitted by a human contributor; the code and test were run locally.