Add timeout for remote model list loading#6551
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a 5-second timeout for fetching remote model configurations and adds a corresponding unit test. The review feedback highlights a potential performance and user experience issue where repeated network requests are made on every lookup, recommending the implementation of an in-memory cache. Additionally, it is suggested to make the fetch timeout configurable via an environment variable.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| try { | ||
| if (isValidUrl(modelFile)) { | ||
| const resp = await axios.get(modelFile) | ||
| const resp = await axios.get(modelFile, { timeout: MODEL_LIST_FETCH_TIMEOUT_MS }) |
There was a problem hiding this comment.
Performance & UX Issue: Repeated Network Requests and Timeouts
Currently, getRawModelFile is called on every single model configuration lookup (e.g., in getModelConfig, getModelConfigByModelName, getModels, and getRegions).
With the new 5-second timeout:
- When Online: Every single lookup will trigger a redundant HTTP request to GitHub, causing unnecessary latency and potentially hitting GitHub's rate limits.
- When Offline / Slow Connection: Every single lookup will block for 5 seconds before falling back to the local file, leading to a severely degraded user experience and laggy UI.
Recommendation
Implement an in-memory cache for the loaded models so that the remote file (or local fallback) is only fetched/read once per application lifecycle.
There was a problem hiding this comment.
Addressed in c992188. The loader now caches the loaded model file per model-list source and supports MODEL_LIST_FETCH_TIMEOUT_MS with a default fallback.
Validation: git diff --check and ./node_modules/.bin/jest src/modelLoader.test.ts --runInBand from packages/components.
| import * as path from 'path' | ||
| import { INodeOptionsValue } from './Interface' | ||
|
|
||
| const MODEL_LIST_FETCH_TIMEOUT_MS = 5000 |
There was a problem hiding this comment.
It is recommended to make the fetch timeout configurable via an environment variable. This allows users in restricted network environments, slow proxies, or air-gapped systems to adjust the timeout value as needed.
const MODEL_LIST_FETCH_TIMEOUT_MS = process.env.MODEL_LIST_FETCH_TIMEOUT_MS
? parseInt(process.env.MODEL_LIST_FETCH_TIMEOUT_MS, 10) || 5000
: 5000There was a problem hiding this comment.
Addressed in c992188. The loader now caches the loaded model file per model-list source and supports MODEL_LIST_FETCH_TIMEOUT_MS with a default fallback.
Validation: git diff --check and ./node_modules/.bin/jest src/modelLoader.test.ts --runInBand from packages/components.
Summary
Tests
Notes
Fixes #6513