Conversation
The Problem The second sendMessage call doesn't wait for its streaming subscription to be established. This creates a race condition: - The agent receives message2 and immediately sends events (artifact-2 + completion) - But the streamConsumer subscription might not be fully wired up yet - The events get delivered to the resubConsumer (which is already established) but missed by the streamConsumer The Fix Add the awaitStreamingSubscription() pattern before the second sendMessage call: Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
Summary of ChangesHello @ehsavoie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a known flaky test ( Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix a flaky test by introducing a wait for a streaming subscription to be established. While the intention is correct, the implementation contains a logical flaw where the wait happens after the action that triggers events, which doesn't fully eliminate the race condition. I've pointed out this issue and suggested a different approach, while also noting that a more fundamental change to the test API might be necessary for a robust solution.
| getClient().sendMessage(message2, List.of(streamConsumer), null); | ||
|
|
||
| // Ensure subscription is established before agent sends events | ||
| assertTrue(streamSubscriptionLatch.await(15, TimeUnit.SECONDS), | ||
| "Stream subscription should be established"); |
There was a problem hiding this comment.
The await call is placed after getClient().sendMessage(...), which doesn't fully resolve the race condition. The sendMessage call triggers the agent to send events immediately. These events could be sent and missed by the client before this await completes, especially if the client-side consumer is not fully wired up.
To reliably fix this, you should wait for the subscription to be established before triggering the agent. The await should be before sendMessage. I've suggested this change below.
However, this will likely lead to a deadlock, as sendMessage is what triggers the subscription creation that awaitStreamingSubscription is waiting for. This indicates a deeper issue with the test's design or the sendMessage API, which might need a more comprehensive fix to allow waiting for the subscription to be ready before events are generated.
| getClient().sendMessage(message2, List.of(streamConsumer), null); | |
| // Ensure subscription is established before agent sends events | |
| assertTrue(streamSubscriptionLatch.await(15, TimeUnit.SECONDS), | |
| "Stream subscription should be established"); | |
| // Ensure subscription is established before agent sends events | |
| assertTrue(streamSubscriptionLatch.await(15, TimeUnit.SECONDS), | |
| "Stream subscription should be established"); | |
| getClient().sendMessage(message2, List.of(streamConsumer), null); |
The Problem
The second sendMessage call doesn't wait for its streaming subscription to be established. This creates a race condition:
The Fix
Add the awaitStreamingSubscription() pattern before the second sendMessage call:
Fixes #627 🦕