Skip to content

Conversation

@DineshThumma9
Copy link
Contributor

Fixes issue where /run_sse endpoint sometimes fails to close the SSE connection after the model's final response, causing client-side hangs.

Changes:

  • Add 'data: [DONE]' termination signal after all events streamed
  • Send [DONE] in error path as well for consistency
  • Update test to filter out [DONE] signal
  • Run autoformat.sh for code style compliance

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
SSE Events don't send explicit done or any kind of termination signal which results client side guessing
or hanging for termination signal

Solution:
I have added data:[DONE] event after end of sse
So client know what event to check on termination

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

All test case passes

Manual End-to-End (E2E) Tests:
I have tested locally using local models and passed

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Fixes issue where /run_sse endpoint sometimes fails to close
the SSE connection after the model's final response, causing
client-side hangs.

Changes:
- Add 'data: [DONE]' termination signal after all events streamed
- Send [DONE] in error path as well for consistency
- Update test to filter out [DONE] signal
- Run autoformat.sh for code style compliance
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @DineshThumma9, 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 significantly improves the reliability of Server-Sent Events (SSE) by implementing a clear termination signal. Previously, clients could experience hangs due to the lack of an explicit end-of-stream indicator. By adding a 'data: [DONE]' message, the system now provides a robust mechanism for clients to detect when an SSE stream has concluded, whether successfully or due to an error, thereby enhancing the overall stability and user experience of streaming data.

Highlights

  • Explicit SSE Stream Termination: Introduced an explicit 'data: [DONE]' signal to the Server-Sent Events (SSE) stream endpoint to clearly indicate the end of a stream, resolving client-side hanging issues.
  • Consistent Error Handling: The 'data: [DONE]' termination signal is now also sent in error paths, ensuring consistent stream closure regardless of success or failure.
  • Test Updates: Unit tests for SSE streaming have been updated to correctly filter out the new 'data: [DONE]' signal when parsing events.
  • Code Style Compliance: The entire codebase was autoformatted using 'autoformat.sh' to maintain consistent code style.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Jan 21, 2026
@DineshThumma9
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces an explicit data: [DONE] termination signal to the SSE stream endpoint, which is a crucial improvement for preventing client-side hangs by clearly indicating the end of the stream. This signal is correctly implemented in both successful and error paths, enhancing the robustness of the SSE connection handling. The corresponding unit test has also been appropriately updated to account for this new termination signal. Additionally, several minor stylistic changes, such as reformatting long string literals and removing redundant parentheses, have been applied across various files, contributing to better code readability and consistency.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where the /run_sse endpoint sometimes failed to close SSE connections, leading to client-side hangs. The fix involves adding an explicit data: [DONE] termination signal after all events have been streamed, including in error paths, to ensure consistent connection closure. The changes also include updates to the relevant test cases to filter out this new [DONE] signal, and the codebase has been autoformatted for style compliance. The changes are well-aligned with the problem description and provide a robust solution for reliable SSE stream termination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

live [Component] This issue is related to live, voice and video chat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants