abhigyanpatwari/GitNexus · error · HttpEmbeddingError
Embedding request timed out after ${timeoutMs}ms (${safeUrl(
Error message
Embedding request timed out after ${timeoutMs}ms (${safeUrl(url)}, batch ${batchIndex}) What it means
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.
Source
Thrown at gitnexus/src/core/embeddings/http-client.ts:513
throw new HttpEmbeddingError(
`Embedding request cancelled (${safeUrl(url)}, batch ${batchIndex})`,
{ cause: err },
);
}
// Retries are exhausted on a bad 2xx body. Surface the message the sentinel
// carried, keeping the underlying parse error in `cause` only — the body
// text must never reach the `sanitizeReason` fallback and leak to stderr.
if (err instanceof RetryableEmbeddingBodyError) {
throw new HttpEmbeddingError(err.terminalMessage, { cause: err.cause });
}
if (err instanceof CircuitOpenError) {
throw new HttpEmbeddingError(
`Embedding endpoint circuit open (${safeUrl(url)}, batch ${batchIndex}): retry in ${Math.ceil(err.retryAfterMs / 1000)}s`,
{ cause: err },
);
}
if (err instanceof DOMException && err.name === 'TimeoutError') {
throw new HttpEmbeddingError(
`Embedding request timed out after ${timeoutMs}ms (${safeUrl(url)}, batch ${batchIndex})`,
{ cause: err },
);
}
if (err instanceof ResilientFetchExhaustedError) {
throw new HttpEmbeddingError(
`Embedding endpoint returned ${err.response.status} (${safeUrl(url)}, batch ${batchIndex})`,
{ cause: err },
);
}
const reason = sanitizeReason(err instanceof Error ? err.message : String(err), url, apiKey);
const safeCause = new Error(reason);
safeCause.name = err instanceof Error ? err.name : 'EmbeddingTransportError';
throw new HttpEmbeddingError(
`Embedding request failed (${safeUrl(url)}, batch ${batchIndex}): ${reason}`,
{ cause: safeCause },
);
}View on GitHub (pinned to d540b00184)
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.
Example fix
// before # default 180s timeout exceeded on a slow model // after export GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS=300000
Defensive patterns
Strategy: validation
Validate before calling
// Raise the per-attempt timeout before the run if you expect slow responses:
const t = parseInt(process.env.GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS ?? '180000', 10);
if (t > 300000) {
throw new Error('GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS capped at 300000');
} Type guard
import { isHttpEmbeddingError } from 'gitnexus';
const isTimeout = (e: unknown): boolean =>
isHttpEmbeddingError(e) && e instanceof Error && e.message.includes('timed out'); Try / catch
try {
await httpEmbed(texts);
} catch (e) {
if (isTimeout(e)) {
// increase GITNEXUS_EMBEDDING_HTTP_TIMEOUT_MS (<=300000) or reduce input size
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Embedding endpoint returned an unparseable response (${safeU
- Embedding endpoint circuit open (${safeUrl(url)}, batch ${ba
- Embedding endpoint returned ${err.response.status} (${safeUr
- Local semantic embeddings are unavailable: the optional embe
- Failed to download embedding model: ${errMsg} ${endpointHi
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/fba250858298381c.
Report an issue: GitHub.