Repository navigation
fix(a2a): abort the in-flight HTTP exchange when a streaming call is cancelled (issue #277) - #336
Merged
Conversation
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.
Describe what this PR does / why we need it
Fixes #277: cancelling a streaming A2A call only stopped event delivery. The producer runs a synchronous
HttpClient5exchange on abounded-elasticworker, so when the remote peer had already sent response headers and then stayed silent, the cancellation was never observed: the worker remained blocked inreadLine(), and the connection was only closed onceexecutereturned. Cancelling therefore neither released the bulkhead thread nor the connection.Does this pull request fix one issue?
Fixes #277
Describe how you did it
sink.onCancel(...)callsHttpPost#cancel()(aborts the exchange when the request is already executing) and closes theCloseableHttpClientcreated for this invocation (covers the window before the request is bound to an execution and unblocks a reader whose peer went quiet). Both steps are idempotent, and the client is per-invocation, so no shared pool or shared client is ever closed.sink.isCancelled()check right beforeexecuteavoids starting a request that was cancelled while the producer was still being set up.!sink.isCancelled(); non-cancellation failures keep the existing error text and done terminal (unchanged contract, cf. [BUG][OPT-22] A2A 传输与解析失败应传播结构化错误而非正常文本完成 #213). Cancelled runs emit neither.How was it tested / verified?
New
A2aStreamCancellationTest(offline, localcom.sun.net.httpserverfixture):dispose();Red before the fix (test run on pristine
04c5686fe):Tests run: 4, Failures: 3— every cancellation case keeps the worker blocked. Green after:Tests run: 4, Failures: 0; module regression shows no new failures beyond the pre-existing Windows-only ones; checkstyle passes.Additional notes