Skip to content

feat: make PROVIDER_TIMEOUT_MS configurable via environment variable#1607

Open
brian-c11 wants to merge 1 commit intomnfst:mainfrom
brian-c11:fix/configurable-provider-timeout
Open

feat: make PROVIDER_TIMEOUT_MS configurable via environment variable#1607
brian-c11 wants to merge 1 commit intomnfst:mainfrom
brian-c11:fix/configurable-provider-timeout

Conversation

@brian-c11
Copy link
Copy Markdown

@brian-c11 brian-c11 commented Apr 18, 2026

Summary

Fixes #1583

  • Replaces the hardcoded 180_000 ms timeout in provider-client.ts with a value read from process.env.PROVIDER_TIMEOUT_MS, falling back to 180_000 if 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 = true from the client disconnect and re-throw instead of triggering the fallback chain.

Solution

const PROVIDER_TIMEOUT_MS = parseInt(process.env.PROVIDER_TIMEOUT_MS ?? '', 10) || 180_000;

Self-hosted users can now set a lower timeout in docker-compose.yml:

environment:
  PROVIDER_TIMEOUT_MS: 45000

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

  • No PROVIDER_TIMEOUT_MS env var set → timeout defaults to 180_000
  • PROVIDER_TIMEOUT_MS=45000 → timeout uses 45000
  • PROVIDER_TIMEOUT_MS=abc (invalid) → timeout falls back to 180_000

🤖 Generated with Claude Code


Summary by cubic

Make the provider request timeout configurable via the PROVIDER_TIMEOUT_MS environment 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.

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>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Make PROVIDER_TIMEOUT_MS configurable via environment variable

2 participants