Skip to content

[BUG] Ollama model details concurrent fetch is a single-point-of-failure (Promise.all error) #851

Description

@edelauna

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

  1. Install multiple models in local Ollama (e.g. llama3.2, codegemma).
  2. 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).
  3. Launch the extension and attempt to fetch/select Ollama models.
  4. Expected Result: The extension successfully lists all healthy models, ignoring/logging the single failing one.
  5. 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)
	})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions