Context
In src/api/providers/fetchers/ollama.ts within the getOllamaModels function, individual model details are retrieved concurrently using Promise.all on an array of axios.post requests:
for (const ollamaModel of parsedResponse.data.models) {
modelInfoPromises.push(
axios
.post<OllamaModelInfoResponse>(
`${baseUrl}/api/show`,
{
model: ollamaModel.model,
},
{ headers },
)
.then((ollamaModelInfo) => {
const modelInfo = parseOllamaModel(ollamaModelInfo.data)
// Only include models that support native tools
if (modelInfo) {
models[ollamaModel.name] = modelInfo
}
}),
)
}
await Promise.all(modelInfoPromises)
If a single POST request to /api/show fails (due to a corrupt model registry, local server overload, or network timeout), the entire Promise.all rejects. This causes the main catch block to execute, logging the error and returning an empty models object.
As a consequence, a single unhealthy or corrupt Ollama model completely disables model listing, rendering all otherwise healthy models unavailable to the user.
Steps to Reproduce
- Install multiple models in local Ollama (e.g.
llama3.2, codegemma).
- Induce a state where one of the models fails to show details (e.g., simulated timeout or a corrupt manifest leading to failure on the
/api/show endpoint).
- Launch the extension and attempt to fetch/select Ollama models.
- Expected Result: The extension successfully lists all healthy models, ignoring/logging the single failing one.
- Actual Result: The models list is completely empty, and an error warning is printed in logs.
Proposed Solution
Append a .catch() block to the individual model details POST promises inside the mapping loop, so individual failures resolve cleanly as undefined and allow Promise.all to successfully complete and list all other healthy models:
axios
.post<OllamaModelInfoResponse>(
`${baseUrl}/api/show`,
{ model: ollamaModel.model },
{ headers }
)
.then((ollamaModelInfo) => {
const modelInfo = parseOllamaModel(ollamaModelInfo.data)
if (modelInfo) {
models[ollamaModel.name] = modelInfo
}
})
.catch((error) => {
console.error(`Error fetching details for model ${ollamaModel.model}:`, error)
})
Context
In
src/api/providers/fetchers/ollama.tswithin thegetOllamaModelsfunction, individual model details are retrieved concurrently usingPromise.allon an array ofaxios.postrequests:If a single POST request to
/api/showfails (due to a corrupt model registry, local server overload, or network timeout), the entirePromise.allrejects. This causes the maincatchblock to execute, logging the error and returning an emptymodelsobject.As a consequence, a single unhealthy or corrupt Ollama model completely disables model listing, rendering all otherwise healthy models unavailable to the user.
Steps to Reproduce
llama3.2,codegemma)./api/showendpoint).Proposed Solution
Append a
.catch()block to the individual model details POST promises inside the mapping loop, so individual failures resolve cleanly asundefinedand allowPromise.allto successfully complete and list all other healthy models: