TencentCloud/TencentDB-Agent-Memory · error
Upstream request failed
Error message
Upstream request failed
What it means
The OpenAI-style handler.ts forwardWithRetry mirrors the Anthropic one: when the final retry attempt fails (excluding rate-limit errors that must propagate), the cause is logged via pipe.error('RETRY_FORWARD', ...) and a generic Error('Upstream request failed') is thrown. The generic message intentionally hides the underlying timeout/network detail from callers.
Source
Thrown at MemoryProxy/src/handler.ts:426
};
if (forwardTimeoutMs > 0) {
retryFetchOpts.signal = AbortSignal.timeout(forwardTimeoutMs);
}
upstreamResp = await fetch(target.retryTarget.url, retryFetchOpts);
if (upstreamResp.ok) {
pipe.info("RETRY_SUCCESS", `Retry returned ${upstreamResp.status}`);
} else {
pipe.error("RETRY_FAILED", `Retry returned ${upstreamResp.status}`);
}
return { resp: upstreamResp, retried: true };
} catch (retryErr: unknown) {
if (isRateLimitExceededError(retryErr)) throw retryErr;
if (retryErr instanceof DOMException && retryErr.name === "TimeoutError") {
pipe.error("RETRY_FORWARD", `Timeout after ${forwardTimeoutMs / 1000}s`);
} else {
pipe.error("RETRY_FORWARD", retryErr);
}
throw new Error("Upstream request failed");
}
}
if (forwardFailed && !shouldRetry) {
throw new Error("Upstream request failed");
}
if (!upstreamResp) {
throw new Error("No upstream response available");
}
return { resp: upstreamResp, retried: false };
}
/** Main handler for POST /v1/chat/completions (OpenAI compat). */
export async function handleChatCompletions(
c: Context,
config: ProxyConfig,View on GitHub (pinned to 3efcd317b8)
Solutions
- Read the RETRY_FORWARD log entry emitted just before the throw to identify timeout vs network error
- Increase forwardTimeoutMs if timeouts occur on long generations
- Verify egress connectivity/proxy settings from the proxy host to the upstream provider
- Enable longer/backoff retry or circuit-breaking upstream failover if available
Example fix
// before
throw new Error("Upstream request failed");
// after
throw new Error("Upstream request failed", { cause: retryErr }); // preserve timeout/network detail for callers Defensive patterns
Strategy: retry
Validate before calling
const reachable = await fetch(upstreamHost, { method: 'HEAD', signal: AbortSignal.timeout(3000) }).then(r => r.status < 500).catch(() => false);
if (!reachable) throw new Error(`upstream ${upstreamHost} unreachable before forwarding`); Type guard
function isUpstreamRequestFailed(e: unknown): boolean {
return e instanceof Error && e.message === 'Upstream request failed';
} Try / catch
try {
return await forwardWithRetry(req, pipe);
} catch (e) {
if (isUpstreamRequestFailed(e) && !isRateLimitExceededError(e)) {
await backoff(retryCount++);
return forwardWithRetry(req, pipe);
}
throw e;
} Prevention
- Correlate with the RETRY_FORWARD log to distinguish timeout vs network error
- Tune forwardTimeoutMs against measured upstream latency
- Monitor egress/proxy health from the proxy host
- Cap retry storms with backoff and circuit breaking
When it happens
Trigger: Every forward attempt to the upstream LLM provider failed within the retry loop — final attempt threw (network error, reset, or TimeoutError after forwardTimeoutMs), or returned a retryable failure that then exhausted attempts.
Common situations: Provider outage, aggressive forwardTimeoutMs for slow completions, corporate proxy blocking egress, upstream 5xx storms exhausting the retry budget.
Related errors
- Upstream request failed
- No upstream response available
- No upstream response available
- llm.provider=proxy 需要 memory 系统用户 key —— 请在 yaml metadata.sy
- [instance-config] Config source returned empty VDB config fo
AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01).
Data as JSON: /api/errors/64782e4bf603258e.
Report an issue: GitHub.