MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / fetchWithTimeout

Function fetchWithTimeout

src/setup/model-detector.ts:61–73  ·  view source on GitHub ↗

* Fetch with timeout helper. We don't want a wizard step to hang for 30s on a * stuck socket, so every probe gets a hard budget.

(url: string, timeoutMs = PROBE_TIMEOUT_MS)

Source from the content-addressed store, hash-verified

59 * stuck socket, so every probe gets a hard budget.
60 */
61async function fetchWithTimeout(url: string, timeoutMs = PROBE_TIMEOUT_MS): Promise<Response | null> {
62 const controller = new AbortController();
63 const timer = setTimeout(() => controller.abort(), timeoutMs);
64 try {
65 const r = await fetch(url, { signal: controller.signal });
66 return r;
67 } catch (e: any) {
68 logger.debug(`probe failed: ${url}`, { err: e?.message ?? String(e) });
69 return null;
70 } finally {
71 clearTimeout(timer);
72 }
73}
74
75/** Probe Ollama daemon for installed models. */
76export async function detectOllamaModels(baseUrl = 'http://localhost:11434'): Promise<DetectedModel[]> {

Callers 3

detectOllamaModelsFunction · 0.85
detectLMStudioModelsFunction · 0.85

Calls 2

abortMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected