Handle ERR_STREAM_PREMATURE_CLOSE as a retryable error#25360
Handle ERR_STREAM_PREMATURE_CLOSE as a retryable error#25360RbBtSn0w wants to merge 1 commit intogoogle-gemini:mainfrom
Conversation
Added ERR_STREAM_PREMATURE_CLOSE to RETRYABLE_NETWORK_CODES to automatically recover from premature stream closures during long generation. * test(core): add regression test for ERR_STREAM_PREMATURE_CLOSE with large content
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, 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 enhances the reliability of streaming interactions by allowing the system to automatically recover from premature stream closures. By classifying this specific Node.js error as a retryable event, the application can now gracefully re-initiate requests that fail due to unstable network conditions or long-lived HTTP/2 streams, ensuring a smoother user experience for large-payload sessions. Highlights
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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds ERR_STREAM_PREMATURE_CLOSE to the list of retryable network error codes in the core package. It also includes a new unit test to verify that the chat system correctly handles and retries when a stream closes prematurely during content generation. I have no feedback to provide.
Added ERR_STREAM_PREMATURE_CLOSE to RETRYABLE_NETWORK_CODES to automatically recover from premature stream closures during long generation.
Summary
#This PR resolves the frequent ERR_STREAM_PREMATURE_CLOSE errors encountered during long-form content generation or large-payload sessions. By categorizing this specific Node.js error code as a retryable network exception, we activate the system's built-in
"retry-with-context" mechanism, significantly improving the reliability of streaming interactions.
Details
Related Issues
#25253
How to Validate
The fix has been rigorously verified using a TDD (Test-Driven Development) workflow:
Validation Command:
1 npm test -w @google/gemini-cli-core -- src/core/geminiChat_network_retry.test.ts
Expected Result: All 8 network-related retry tests (including the new regression test) pass successfully.
Pre-Merge Checklist