Skip to content

Commit 29e414a

Browse files
committed
fix(client): signal completion for final SSE events
Signal normal completion before auto-closing streams for final events so cancellation cannot report a contradictory terminal outcome. Apply this to the shared listener and the v0.3 JSON-RPC listener. This fixes #1170
1 parent 81dfe0e commit 29e414a

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

‎client/transport/spi/src/main/java/org/a2aproject/sdk/client/transport/spi/sse/AbstractSSEEventListener.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ protected void handleEvent(StreamingEventKind event, @Nullable Future<Void> futu
118118
// This covers late subscriptions to completed tasks and ensures no connection leaks
119119
if (shouldAutoClose(event) && future != null) {
120120
LOGGER.fine("Auto-closing SSE connection for final event: " + event.getClass().getSimpleName());
121+
signalTerminal(null);
121122
future.cancel(true); // close SSE channel
122123
}
123124
}

‎compat-0.3/client/transport/jsonrpc/src/main/java/org/a2aproject/sdk/compat03/client/transport/jsonrpc/sse/SSEEventListener_v0_3.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private void handleMessage(JsonObject jsonObject, Future<Void> future) throws Js
7272
StreamingEventKind_v0_3 event = JsonUtil_v0_3.fromJson(resultJson, StreamingEventKind_v0_3.class);
7373
eventHandler.accept(event);
7474
if (event instanceof TaskStatusUpdateEvent_v0_3 tsue && tsue.isFinal()) {
75+
signalTerminal(null);
7576
future.cancel(true); // close SSE channel
7677
}
7778
} else {

0 commit comments

Comments
 (0)