fix(core): reduce default API timeout to 60s and enable retries for undici timeouts#26191
fix(core): reduce default API timeout to 60s and enable retries for undici timeouts#26191
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 improves the resilience and responsiveness of API requests by shortening the default timeout period and ensuring that specific timeout-related errors are correctly handled by the existing retry mechanism. By mapping Undici-specific timeout codes to standard network error codes, the system can now automatically recover from transient connection or header timeouts. 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
|
|
Size Change: +157 B (0%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Code Review
This pull request reduces the default fetch timeout from five minutes to 60 seconds and updates the retry logic to map specific Undici timeout error codes to a generic 'ETIMEDOUT' status, supported by a new test case. Feedback suggests that a 60-second timeout may be too aggressive for long-running LLM generations and recommends retaining the original Undici error codes to preserve telemetry detail while still enabling retries.
|
is there any data backing up with timeout number chosen? |
|
From the issue, there's no reasonable data by the author. This was selected a reasonable client-side timeout value #18030 |
Summary
API requests could hang for up to 5 minutes (default undici timeout) when the backend or local proxy was unresponsive. This PR reduces the default timeout to 60 seconds and ensures that these timeouts are automatically retried.
Details
defaultTimeoutinpackages/core/src/utils/fetch.tsfrom 300,000ms to 60,000ms.getNetworkErrorCodeinpackages/core/src/utils/retry.tsto map Undici-specific timeout error codes (UND_ERR_HEADERS_TIMEOUT,UND_ERR_BODY_TIMEOUT,UND_ERR_CONNECT_TIMEOUT) to the standardETIMEDOUTcode.Related Issues
Fixes #18030
How to Validate
npm test -w @google/gemini-cli-core -- src/utils/retry.test.tsto verify the new test case for Undici timeouts.npm test -w @google/gemini-cli-core -- src/utils/fetch.test.tsto ensure no regressions in fetch utilities.Pre-Merge Checklist