fix(core): retry on ERR_STREAM_PREMATURE_CLOSE errors#26519
Conversation
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 robustness of the core streaming functionality by explicitly handling 'ERR_STREAM_PREMATURE_CLOSE' as a retryable error. This ensures that transient network issues causing premature stream closures do not result in immediate failure, improving the overall reliability of content generation streams. Highlights
Ignored Files
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 the 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 counterproductive. 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 introduces a regression test to ensure that streaming content generation successfully retries when this specific error occurs mid-stream. I have no feedback to provide as there were no review comments.
|
Size Change: +28 B (0%) Total Size: 34 MB
ℹ️ View Unchanged
|
Summary
This PR fixes the frequent
ERR_STREAM_PREMATURE_CLOSEerrors reported in #25253. These errors occur when a response stream is interrupted, which is common during long generations. By adding this error code to the retryable list, the CLI can now automatically recover from these transient network hiccups.Details
ERR_STREAM_PREMATURE_CLOSEtoRETRYABLE_NETWORK_CODESinpackages/core/src/utils/retry.ts.GeminiChatto catch and handle this error..gemini/settings.jsonwhich was accidentally deleted in a previous commit.Related Issues
Fixes #25253
How to Validate
I have added a regression test case to
packages/core/src/core/geminiChat_network_retry.test.tsthat:ERR_STREAM_PREMATURE_CLOSEerror.To run the test:
npm test -w @google/gemini-cli-core -- src/core/geminiChat_network_retry.test.tsPre-Merge Checklist