{"record":{"id":"fba250858298381c","repo":"abhigyanpatwari/GitNexus","slug":"embedding-request-timed-out-after-timeoutms-ms","errorCode":null,"errorMessage":"Embedding request timed out after ${timeoutMs}ms (${safeUrl(url)}, batch ${batchIndex})","messagePattern":"Embedding request timed out after (.+?)ms \\((.+?), batch (.+?)\\)","errorType":"exception","errorClass":"HttpEmbeddingError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/http-client.ts","lineNumber":513,"sourceCode":"      throw new HttpEmbeddingError(\n        `Embedding request cancelled (${safeUrl(url)}, batch ${batchIndex})`,\n        { cause: err },\n      );\n    }\n    // Retries are exhausted on a bad 2xx body. Surface the message the sentinel\n    // carried, keeping the underlying parse error in `cause` only — the body\n    // text must never reach the `sanitizeReason` fallback and leak to stderr.\n    if (err instanceof RetryableEmbeddingBodyError) {\n      throw new HttpEmbeddingError(err.terminalMessage, { cause: err.cause });\n    }\n    if (err instanceof CircuitOpenError) {\n      throw new HttpEmbeddingError(\n        `Embedding endpoint circuit open (${safeUrl(url)}, batch ${batchIndex}): retry in ${Math.ceil(err.retryAfterMs / 1000)}s`,\n        { cause: err },\n      );\n    }\n    if (err instanceof DOMException && err.name === 'TimeoutError') {\n      throw new HttpEmbeddingError(\n        `Embedding request timed out after ${timeoutMs}ms (${safeUrl(url)}, batch ${batchIndex})`,\n        { cause: err },\n      );\n    }\n    if (err instanceof ResilientFetchExhaustedError) {\n      throw new HttpEmbeddingError(\n        `Embedding endpoint returned ${err.response.status} (${safeUrl(url)}, batch ${batchIndex})`,\n        { cause: err },\n      );\n    }\n    const reason = sanitizeReason(err instanceof Error ? err.message : String(err), url, apiKey);\n    const safeCause = new Error(reason);\n    safeCause.name = err instanceof Error ? err.name : 'EmbeddingTransportError';\n    throw new HttpEmbeddingError(\n      `Embedding request failed (${safeUrl(url)}, batch ${batchIndex}): ${reason}`,\n      { cause: safeCause },\n    );\n  }","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/http-client.ts#L495-L531","documentation":"An HttpEmbeddingError thrown from httpEmbedBatch's catch block when a DOMException with name 'TimeoutError' escapes resilientFetch — i.e. the per-attempt AbortSignal.timeout(timeoutMs) fired before the endpoint responded. The message reports the configured timeout (timeoutMs, from GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS, default 180000ms, capped at 300000ms). Note this is distinct from a caller abort (error 126): a timeout is the client giving up on a stalled endpoint.","triggerScenarios":"httpEmbedBatch where a single attempt exceeds timeoutMs without a response. The timeout signal is composed with the caller signal via AbortSignal.any, so either firing aborts the fetch; a TimeoutError specifically means the per-attempt deadline hit. Large batches, slow models, or a slow network commonly trigger it.","commonSituations":"Large HTTP_BATCH_SIZE (64) sent to a slow model. Embedding a very long input that makes the model slow. High-latency or congested link to the provider. Default 180s timeout exceeded on cold-start of a large model. Provider queueing.","solutions":["Raise the per-attempt timeout: set GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS (max 300000 = 5 minutes).","Reduce the work per request: embed smaller text chunks or fewer texts per call (note HTTP_BATCH_SIZE is currently a fixed constant of 64).","If timeouts are intermittent, the retry loop already retries up to maxAttempts; raising GITNEXUS_EMBEDDING_MAX_ATTEMPTS gives more chances.","Check provider latency/queueing — a permanently slow endpoint needs a faster model or a closer region."],"exampleFix":"// before\n# default 180s timeout exceeded on a slow model\n\n// after\nexport GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS=300000","handlingStrategy":"validation","validationCode":"// Raise the per-attempt timeout before the run if you expect slow responses:\nconst t = parseInt(process.env.GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS ?? '180000', 10);\nif (t > 300000) {\n  throw new Error('GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS capped at 300000');\n}","typeGuard":"import { isHttpEmbeddingError } from 'gitnexus';\nconst isTimeout = (e: unknown): boolean =>\n  isHttpEmbeddingError(e) && e instanceof Error && e.message.includes('timed out');","tryCatchPattern":"try {\n  await httpEmbed(texts);\n} catch (e) {\n  if (isTimeout(e)) {\n    // increase GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS (<=300000) or reduce input size\n  }\n  throw e;\n}","preventionTips":["Set GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS appropriate to your model latency (up to 300000).","Embed shorter text chunks to reduce per-request latency.","Monitor p99 endpoint latency; a slow region/model will trip this repeatedly."],"tags":["timeout","network","endpoint","embeddings"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}