Skip to content

Commit 8c8888a

Browse files
authored
feat: increase Ollama API timeout values and extract as constants (RooCodeInc#5778)
- Increase embedding request timeout from 10s to 60s - Increase validation request timeouts from 5s to 30s - Extract timeout values as module-level constants for better maintainability - OLLAMA_EMBEDDING_TIMEOUT_MS = 60000 (60 seconds) - OLLAMA_VALIDATION_TIMEOUT_MS = 30000 (30 seconds)
1 parent d513b9c commit 8c8888a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/services/code-index/embedders/ollama.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { withValidationErrorHandling, sanitizeErrorMessage } from "../shared/val
77
import { TelemetryService } from "@roo-code/telemetry"
88
import { TelemetryEventName } from "@roo-code/types"
99

10+
// Timeout constants for Ollama API requests
11+
const OLLAMA_EMBEDDING_TIMEOUT_MS = 60000 // 60 seconds for embedding requests
12+
const OLLAMA_VALIDATION_TIMEOUT_MS = 30000 // 30 seconds for validation requests
13+
1014
/**
1115
* Implements the IEmbedder interface using a local Ollama instance.
1216
*/
@@ -61,7 +65,7 @@ export class CodeIndexOllamaEmbedder implements IEmbedder {
6165

6266
// Add timeout to prevent indefinite hanging
6367
const controller = new AbortController()
64-
const timeoutId = setTimeout(() => controller.abort(), 10000) // 10 second timeout
68+
const timeoutId = setTimeout(() => controller.abort(), OLLAMA_EMBEDDING_TIMEOUT_MS)
6569

6670
const response = await fetch(url, {
6771
method: "POST",
@@ -140,7 +144,7 @@ export class CodeIndexOllamaEmbedder implements IEmbedder {
140144

141145
// Add timeout to prevent indefinite hanging
142146
const controller = new AbortController()
143-
const timeoutId = setTimeout(() => controller.abort(), 5000) // 5 second timeout
147+
const timeoutId = setTimeout(() => controller.abort(), OLLAMA_VALIDATION_TIMEOUT_MS)
144148

145149
const modelsResponse = await fetch(modelsUrl, {
146150
method: "GET",
@@ -197,7 +201,7 @@ export class CodeIndexOllamaEmbedder implements IEmbedder {
197201

198202
// Add timeout for test request too
199203
const testController = new AbortController()
200-
const testTimeoutId = setTimeout(() => testController.abort(), 5000)
204+
const testTimeoutId = setTimeout(() => testController.abort(), OLLAMA_VALIDATION_TIMEOUT_MS)
201205

202206
const testResponse = await fetch(testUrl, {
203207
method: "POST",

0 commit comments

Comments
 (0)