feat: add timeouts, retry logic, and improved error handling#80
feat: add timeouts, retry logic, and improved error handling#80whereisfarukk wants to merge 2 commits intomainfrom
Conversation
whereisfarukk
commented
Dec 14, 2025
- Model-specific timeouts for chat completions (fixes fast/auto model timeouts)
- Retry logic with exponential backoff for network errors
- Centralized error handling
- Remove console logs for production
…ompletions - Add centralized error handling with handleRequestError() method - Implement model-specific timeouts for chat completions (5min for fast/auto, 3min for pro) - Add retry logic with exponential backoff for transient network errors - Remove console logging statements for production readiness - Simplify error handling while maintaining functionality Fixes timeout issues with vlmrun-orion-1:fast and vlmrun-orion-1:auto models
Summary of ChangesHello @whereisfarukk, 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 enhances the stability and resilience of API interactions by introducing intelligent timeout management, implementing a retry strategy for network fluctuations, and centralizing error reporting. These changes aim to reduce failures due to temporary network issues or long-running model responses, ultimately providing a more robust user experience. 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. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces several important reliability improvements: model-specific timeouts, retry logic for network errors, and centralized error handling. The changes are well-structured and significantly improve the client's resilience.
My review includes a couple of suggestions for improvement:
- In
VlmRunClient.ts, the timeout logic can be made more robust by usingendsWithinstead ofincludesfor model name checks, and by using constants for timeout values to improve maintainability. - The retry logic's backoff is currently linear, not exponential as commented. I've suggested a fix to align the implementation with the comment, which is important for handling transient errors effectively.
| if (data.model.includes(':fast') || data.model.includes(':auto')) { | ||
| timeout = 300000; // 5 minutes for fast/auto | ||
| } else { | ||
| timeout = 180000; // 3 minutes for pro | ||
| } |
There was a problem hiding this comment.
Using includes() to check for model types can be brittle as it can lead to partial matches (e.g., a model named not-so-fast would incorrectly match). Using endsWith() is more robust for checking model suffixes.
Additionally, the timeout values (60000, 300000, 180000) are magic numbers. Consider defining them as named constants at the top of the file for improved readability and maintainability, for example:
const DEFAULT_TIMEOUT_MS = 60 * 1000;
const CHAT_COMPLETION_FAST_AUTO_TIMEOUT_MS = 5 * 60 * 1000;
const CHAT_COMPLETION_PRO_TIMEOUT_MS = 3 * 60 * 1000;| if (data.model.includes(':fast') || data.model.includes(':auto')) { | |
| timeout = 300000; // 5 minutes for fast/auto | |
| } else { | |
| timeout = 180000; // 3 minutes for pro | |
| } | |
| if (data.model.endsWith(':fast') || data.model.endsWith(':auto')) { | |
| timeout = 300000; // 5 minutes for fast/auto | |
| } else { | |
| timeout = 180000; // 3 minutes for pro | |
| } |