feat: make PROVIDER_TIMEOUT_MS configurable via environment variable#1607
Open
brian-c11 wants to merge 1 commit intomnfst:mainfrom
Open
feat: make PROVIDER_TIMEOUT_MS configurable via environment variable#1607brian-c11 wants to merge 1 commit intomnfst:mainfrom
brian-c11 wants to merge 1 commit intomnfst:mainfrom
Conversation
Fixes mnfst#1583 The hardcoded 180s timeout caused fallback chains to fail when upstream clients (e.g. OpenClaw) share the same timeout — both fire simultaneously and the client disconnects first, bypassing Manifest's fallback logic. Reading from PROVIDER_TIMEOUT_MS env var lets self-hosted users set a lower value so fallbacks can complete within the upstream timeout window. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/backend/src/routing/proxy/provider-client.ts">
<violation number="1" location="packages/backend/src/routing/proxy/provider-client.ts:32">
P1: Environment timeout parsing does not reject negative values, so `AbortSignal.timeout()` can throw and break all provider forwarding when the env var is misconfigured.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| } | ||
|
|
||
| const PROVIDER_TIMEOUT_MS = 180_000; | ||
| const PROVIDER_TIMEOUT_MS = parseInt(process.env.PROVIDER_TIMEOUT_MS ?? '', 10) || 180_000; |
There was a problem hiding this comment.
P1: Environment timeout parsing does not reject negative values, so AbortSignal.timeout() can throw and break all provider forwarding when the env var is misconfigured.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/backend/src/routing/proxy/provider-client.ts, line 32:
<comment>Environment timeout parsing does not reject negative values, so `AbortSignal.timeout()` can throw and break all provider forwarding when the env var is misconfigured.</comment>
<file context>
@@ -29,7 +29,7 @@ export interface ForwardResult {
}
-const PROVIDER_TIMEOUT_MS = 180_000;
+const PROVIDER_TIMEOUT_MS = parseInt(process.env.PROVIDER_TIMEOUT_MS ?? '', 10) || 180_000;
/**
</file context>
Suggested change
| const PROVIDER_TIMEOUT_MS = parseInt(process.env.PROVIDER_TIMEOUT_MS ?? '', 10) || 180_000; | |
| const parsedTimeout = Number(process.env.PROVIDER_TIMEOUT_MS); | |
| const PROVIDER_TIMEOUT_MS = Number.isInteger(parsedTimeout) && parsedTimeout >= 0 ? parsedTimeout : 180_000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1583
180_000ms timeout inprovider-client.tswith a value read fromprocess.env.PROVIDER_TIMEOUT_MS, falling back to180_000if unset or invalid.Problem
With matching 180s timeouts between Manifest and upstream clients (e.g. OpenClaw), both fire simultaneously. The client disconnects first, causing Manifest to see
signal.aborted = truefrom the client disconnect and re-throw instead of triggering the fallback chain.Solution
Self-hosted users can now set a lower timeout in
docker-compose.yml:With 45s per attempt: primary (45s) + fallback 1 (45s) + fallback 2 (45s) = 135s — well within a typical 300s upstream timeout, allowing the fallback chain to complete.
Test plan
PROVIDER_TIMEOUT_MSenv var set → timeout defaults to180_000PROVIDER_TIMEOUT_MS=45000→ timeout uses45000PROVIDER_TIMEOUT_MS=abc(invalid) → timeout falls back to180_000🤖 Generated with Claude Code
Summary by cubic
Make the provider request timeout configurable via the
PROVIDER_TIMEOUT_MSenvironment variable instead of a fixed 180s. Defaults to 180000 ms if unset or invalid, allowing fallback chains to complete before upstream client timeouts.Written for commit 6a1a4f4. Summary will update on new commits.