-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Add explicit [DONE] signal to SSE stream endpoint #4226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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
Summary of ChangesHello @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
🧠 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 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
|
|
/gemini review |
There was a problem hiding this 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.
There was a problem hiding this 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.
Fixes issue where /run_sse endpoint sometimes fails to close the SSE connection after the model's final response, causing client-side hangs.
Changes:
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:
All test case passes
Manual End-to-End (E2E) Tests:
I have tested locally using local models and passed
Checklist