[GH-ISSUE #2435] [Issue]: 11-PROV-PERF-timeouts-size-streaming Rust LLM provider calls lack timeout #1188

Closed
opened 2026-10-21 05:28:33 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2435

Originally assigned to: @SpicyMarinara on GitHub.

Summary

11-PROV-PERF-timeouts-size-streaming: Rust LLM provider transport does not configure a request/header/connect timeout for outbound provider calls, so slow or stalled providers can hang longer than legacy allowed.

Links back to #2410.

Expected behavior

Legacy LLM transport used a bounded 5-minute headers timeout while allowing long streaming bodies, and still capped provider response size.

Acceptance criteria:

  • Rust LLM provider HTTP clients have an explicit timeout policy equivalent to the legacy intent.
  • Streaming remains able to run without a short body timeout.
  • Timeout failures surface as provider/network errors without fake success.
  • Add focused mocked-provider proof for a slow/stalled response.

Actual behavior

Refactor Rust LLM provider clients validate URL safety and disable redirects, but provider_http_client builds reqwest::Client without a timeout. Non-stream and stream calls for Cohere, OpenAI-compatible, OpenAI Responses, Anthropic, and Google use that client.

The refactor does cap provider response bodies at 5 MiB, but the timeout part of the surface is missing.

Steps to reproduce

  1. Inspect src-tauri/crates/llm/src/lib.rs.
  2. Follow provider_http_client_for_url into provider_http_client.
  3. Follow provider calls that use provider_http_client_for_url(...).await?.post(...).send().await.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor@09923989
  • Run mode: Tauri desktop / remote runtime
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not checked
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: LLM providers

Logs, screenshots, or video

Static trace proof only. No live provider call was run.

Regression notes

Legacy main used llmFetch with LLM_HEADERS_TIMEOUT = 5 * 60 * 1000, bodyTimeout: 0, and maxResponseBytes: 50 * 1024 * 1024.

Refactor evidence:

  • src-tauri/crates/llm/src/lib.rs:395 validates provider URLs before client creation.
  • src-tauri/crates/llm/src/lib.rs:495 builds the provider client without a timeout.
  • src-tauri/crates/llm/src/lib.rs:1765, :1859, :2067, :3594, and :4008 use the timeoutless provider client for live calls.
  • src-tauri/crates/llm/src/lib.rs:26 and :4205 cap provider response bodies.

Legacy evidence:

  • packages/server/src/services/llm/base-provider.ts:13 defines the 5-minute headers timeout.
  • packages/server/src/services/llm/base-provider.ts:20 routes outgoing LLM fetches through llmFetch.
  • packages/server/src/services/llm/base-provider.ts:35 sets the LLM response cap.

Additional context

Surface ID: 11-PROV-PERF-timeouts-size-streaming.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2435 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `11-PROV-PERF-timeouts-size-streaming`: Rust LLM provider transport does not configure a request/header/connect timeout for outbound provider calls, so slow or stalled providers can hang longer than legacy allowed. Links back to #2410. ## Expected behavior Legacy LLM transport used a bounded 5-minute headers timeout while allowing long streaming bodies, and still capped provider response size. Acceptance criteria: - Rust LLM provider HTTP clients have an explicit timeout policy equivalent to the legacy intent. - Streaming remains able to run without a short body timeout. - Timeout failures surface as provider/network errors without fake success. - Add focused mocked-provider proof for a slow/stalled response. ## Actual behavior Refactor Rust LLM provider clients validate URL safety and disable redirects, but `provider_http_client` builds `reqwest::Client` without a timeout. Non-stream and stream calls for Cohere, OpenAI-compatible, OpenAI Responses, Anthropic, and Google use that client. The refactor does cap provider response bodies at 5 MiB, but the timeout part of the surface is missing. ## Steps to reproduce 1. Inspect `src-tauri/crates/llm/src/lib.rs`. 2. Follow `provider_http_client_for_url` into `provider_http_client`. 3. Follow provider calls that use `provider_http_client_for_url(...).await?.post(...).send().await`. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor@09923989 - Run mode: Tauri desktop / remote runtime - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not checked - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: LLM providers ## Logs, screenshots, or video Static trace proof only. No live provider call was run. ## Regression notes Legacy `main` used `llmFetch` with `LLM_HEADERS_TIMEOUT = 5 * 60 * 1000`, `bodyTimeout: 0`, and `maxResponseBytes: 50 * 1024 * 1024`. Refactor evidence: - `src-tauri/crates/llm/src/lib.rs:395` validates provider URLs before client creation. - `src-tauri/crates/llm/src/lib.rs:495` builds the provider client without a timeout. - `src-tauri/crates/llm/src/lib.rs:1765`, `:1859`, `:2067`, `:3594`, and `:4008` use the timeoutless provider client for live calls. - `src-tauri/crates/llm/src/lib.rs:26` and `:4205` cap provider response bodies. Legacy evidence: - `packages/server/src/services/llm/base-provider.ts:13` defines the 5-minute headers timeout. - `packages/server/src/services/llm/base-provider.ts:20` routes outgoing LLM fetches through `llmFetch`. - `packages/server/src/services/llm/base-provider.ts:35` sets the LLM response cap. ## Additional context Surface ID: `11-PROV-PERF-timeouts-size-streaming`. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:33 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@carter-smalls commented on GitHub (Jun 6, 2026):

Seems like Ai Api timeout conditions. Running npx ai-doctor might point out missing timeout guards and unprotected requests.

<!-- gh-comment-id:4638134447 --> @carter-smalls commented on GitHub (Jun 6, 2026): Seems like Ai Api timeout conditions. Running `npx ai-doctor` might point out missing timeout guards and unprotected requests.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 6, 2026):

Fixed on refactor in commit 360652d5.

What changed:

  • LLM provider clients now set an explicit connect timeout matching the provider response-header timeout policy.
  • Provider request sends now go through a shared headers-timeout wrapper, so stalled headers fail as network/provider errors instead of hanging indefinitely.
  • Streaming responses still receive their body stream after headers arrive; the timeout wrapper is not applied to body chunks.
  • Cohere, OpenAI-compatible, OpenAI Responses, Anthropic, Google, and ChatGPT auth refresh provider sends use the shared wrapper.
  • Added mocked slow-header proof for timeout behavior.

Verification:

  • cargo check --manifest-path src-tauri/Cargo.toml --workspace
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm provider_request_times_out_waiting_for_response_headers -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm provider_ -- --nocapture
  • pnpm check:architecture
<!-- gh-comment-id:4638152551 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed on refactor in commit 360652d5. What changed: - LLM provider clients now set an explicit connect timeout matching the provider response-header timeout policy. - Provider request sends now go through a shared headers-timeout wrapper, so stalled headers fail as network/provider errors instead of hanging indefinitely. - Streaming responses still receive their body stream after headers arrive; the timeout wrapper is not applied to body chunks. - Cohere, OpenAI-compatible, OpenAI Responses, Anthropic, Google, and ChatGPT auth refresh provider sends use the shared wrapper. - Added mocked slow-header proof for timeout behavior. Verification: - cargo check --manifest-path src-tauri/Cargo.toml --workspace - cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm provider_request_times_out_waiting_for_response_headers -- --nocapture - cargo test --manifest-path src-tauri/Cargo.toml -p marinara-llm provider_ -- --nocapture - pnpm check:architecture
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1188
No description provided.