fix: resolve intermittent stream closure failures in EventConsumer#777
Open
kabir wants to merge 2 commits intoa2aproject:mainfrom
Open
fix: resolve intermittent stream closure failures in EventConsumer#777kabir wants to merge 2 commits intoa2aproject:mainfrom
kabir wants to merge 2 commits intoa2aproject:mainfrom
Conversation
Fixes two separate race conditions causing intermittent test failures:
1. Grace period closing streams before final events arrive
- EventConsumer now checks awaitingFinalEvent flag before starting
timeout counter, preventing premature closure when final events are
in-transit through MainEventBusProcessor
- Increased grace period timeout to 150ms for CI environment latency
2. Client auto-close IOException not filtered in testAuthRequiredWorkflow
- AbstractSSEEventListener cancels SSE streams on final events (by design)
- This generates "Stream cancelled" IOException that must be filtered
- testAuthRequiredWorkflow was the only test missing this filter
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request implements a timeout mechanism for final events in the EventConsumer to prevent potential infinite polling. It introduces a maximum wait period (3 seconds) and increases the SSE buffer flush delay to 150ms to improve reliability in CI environments. Review feedback suggests refactoring the clearAwaitingFinalEvent logic into the EventQueue base class to avoid brittle type checking and identifies redundant flag-clearing logic in the ChildQueue dequeue process that should be removed.
server-common/src/main/java/io/a2a/server/events/EventConsumer.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/events/EventQueue.java
Outdated
Show resolved
Hide resolved
server-common/src/main/java/io/a2a/server/events/EventQueue.java
Outdated
Show resolved
Hide resolved
kabir
added a commit
to kabir/a2a-java
that referenced
this pull request
Mar 31, 2026
Runs testAgentToAgentLocalHandling and testNonBlockingWithMultipleMessages in a loop (100 iterations) across 9 parallel jobs (3 Java versions × 3 transports) to capture intermittent failures for analysis. Related to a2aproject#777 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Fixes two separate race conditions causing intermittent test failures:
Grace period closing streams before final events arrive
Client auto-close IOException not filtered in testAuthRequiredWorkflow