fix(opencode): repair chatgpt subscription hang watchdog#29388
fix(opencode): repair chatgpt subscription hang watchdog#29388liuhaoyang wants to merge 5 commits into
Conversation
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Fixes #29420
Summary
Repair the stream watchdog for ChatGPT subscription streams to properly detect and recover from hung connections.
Changes
provider.ts): Replace brokenAbortSignal.timeout()with manualsetTimeout+AbortControllerfor a 5-minute default request timeout. Properly clean up timers infinallyblock and re-throw abort reasons on cancellation.processor.ts): AddwatchStream()wrapper with separate first-byte (30s) and idle (120s) timeouts usingPromise.race. Wire into the LLM stream consumption path and cap retries at 3 attempts.message-v2.ts): ConvertDOMException(TimeoutError)from watchdog into retryableAPIErrorso the retry loop can recover.retry.ts,error.ts): Extend transient error detection to recognize 429/502/503/504 status codes, rate-limit messages, overloaded/gateway-timeout patterns, and deeply-nested ChatGPT error bodies (with depth protection against circular refs).codex.ts): ThreadAbortSignalthroughexchangeCodeForTokens(),refreshAccessToken(), andwaitForOAuthCallback()so Codex auth operations respect caller cancellation.task.ts): Add configurable 5-minute default timeout on subagent tasks with input validation rejecting non-positive values.Test Plan