Uh oh!
There was an error while loading. Please reload this page.
fix: prevent unrecoverable "Failed to fetch" on long sessions - #28707
fix: prevent unrecoverable "Failed to fetch" on long sessions#28707Krypto-Whitehat wants to merge 1 commit into
Conversation
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
The SDK client disabled request timeouts entirely (`req.timeout = false`), causing fetch to hang forever when the Go backend becomes unresponsive. Combined with only 3 retry attempts at 10s max delay, the renderer's fetchMessages call would permanently fail with TypeError: Failed to fetch, freezing the TUI display while the backend continued working in the background. Changes: - Set SDK fetch timeout to 5 minutes (300_000ms) instead of disabled - Increase retry defaults: 5 attempts (was 3), 1s initial delay (was 500ms), 30s max delay (was 10s) for better transient error recovery Fixesanomalyco#28702 Co-Authored-By: OpenClaude (GLM-5.1) <openclaude@gitlawb.com>
f50dfc2 to
14a6c83CompareAutomated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes#28702
Type of change
What does this PR do?
The
TypeError: Failed to fetcherror permanently freezes the TUI display during long sessions. The display goes blank while the loading bar keeps spinning — the backend continues working but the renderer can't fetch messages anymore.The root cause is that the SDK client sets
req.timeout = false, disabling request timeouts entirely. When the Go backend is temporarily unresponsive (GC pause, heavy snapshot, DB operation), the renderer'sfetchMessageshangs forever. Theretryutility only tries 3 times with a 10s max delay, which is insufficient.The fix is straightforward:
packages/sdk/js/src/client.tsandpackages/sdk/js/src/v2/client.ts: Setreq.timeout = 300_000(5 min) instead offalse. This lets the fetch fail after 5 minutes so the retry mechanism can recover.packages/core/src/util/retry.ts: Increase defaultattemptsfrom 3 to 5,delayfrom 500ms to 1000ms, andmaxDelayfrom 10s to 30s. This gives ~31 seconds of exponential backoff retries — enough to ride out transient backend pauses.How did you verify your code works?
Tested on Windows 11 with OpenCode v1.15.7. Before patching, the TUI froze within 10-20 minutes of active agent usage (Prometheus). After applying the
req.timeoutpatch locally, the renderer recovers from transient backend pauses instead of permanently hanging.Screenshots / recordings
N/A — no UI changes, only fetch/retry behavior.
Checklist