Skip to content

fix - #1636

Draft
Forsakenrox wants to merge 2 commits into
Zoo-Code-Org:mainfrom
Forsakenrox:fix-request-timeout
Draft

fix#1636
Forsakenrox wants to merge 2 commits into
Zoo-Code-Org:mainfrom
Forsakenrox:fix-request-timeout

Conversation

@Forsakenrox

Copy link
Copy Markdown

Related GitHub Issue

Closes: # 1407

Description

This PR fixes the TypeError: terminated / UND_ERR_BODY_TIMEOUT error that occurs when OpenAI-compatible provider requests run longer than 5 minutes (e.g., when the agent writes directly to a file, generating long tool calls, or reasoning chains with large models like Qwen3.8 27B).
VS Code bundles its own internal version of undici with a hardcoded 300-second bodyTimeout default. This silently overrides the user-configured apiRequestTimeout (default 600s) at the Node.js fetch layer, causing requests to be forcefully terminated after exactly 5 minutes of idle body streaming.

Test Procedure

Manual testing:

  1. Launch a local OpenAI-compatible inference server (LM Studio, Ollama, or vLLM).
  2. Load a large model (e.g., Qwen3.8 27B Q8 on an A100 40GB, or any model slow enough on consumer hardware).
  3. Configure Zoo Code to use the local endpoint.
  4. Send a prompt that forces long processing time — specifically one instructing the agent to write directly to a file (bypassing the standard streaming UI).
  5. Verify that the request does not fail at ~300 seconds and instead continues streaming until completion (or up to the configured apiRequestTimeout of 600s).

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): If a user would notice this change at a glance (layout, theme tokens, brand elements, empty/error states), I've added or updated a *.visual.tsx snapshot in webview-ui/. See webview-ui/AGENTS.md → "When a UI change needs a snapshot".
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

Does this PR necessitate updates to user-facing documentation?

  • No documentation updates are required.

Additional Notes

  • The resolveTimeoutMs() helper ensures backward compatibility: if the setting is unset or 0, we fall back to DEFAULT_TIMEOUT_MS rather than letting the OpenAI SDK/undici use their own defaults.
  • This fix applies to all OpenAI-compatible providers (not just LM Studio) since they share the same base client initialization path in openai.ts.

Summary by CodeRabbit

  • Bug Fixes
    • Improved connectivity handling for OpenAI requests by using a consistent network transport.
    • Ensured custom connection settings are applied reliably to OpenAI requests.
    • Requests configured with no timeout continue to support extended or uninterrupted operation.
    • Improved reliability for requests that use custom connection settings and longer-running operations.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit-review-active

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f093f8bd-d863-4900-8059-cbeb6f051418

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Fix the failing required CI checks; awaiting-maintainer requires CI and automated review completion.

Review-state labels are managed by this workflow; do not edit them manually.

@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant