Skip to content

fix: fail the async SSE future when the stream errors - #599

Merged
ryber merged 1 commit into
Kong:mainfrom
pcbeingused333:fix/sse-async-stream-error
Nov 15, 2026
Merged

ryber merged 1 commit into
Kong:mainfrom
pcbeingused333:fix/sse-async-stream-error

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

UnirestInstance.sse(url).connect(handler) (async) returns a CompletableFuture<Void>, but JavaClient.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: SseStreamFailureTest starts a local server that promises 1000 bytes, sends one event and hangs up. Before: the future completes normally. After: future.get() throws ExecutionException.

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.

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.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ryber
ryber merged commit b1cf103 into Kong:main Nov 15, 2026
1 check 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.

3 participants