fix: prevent unrecoverable "Failed to fetch" on long sessions#28707
Open
emco1234 wants to merge 1 commit into
Open
fix: prevent unrecoverable "Failed to fetch" on long sessions#28707emco1234 wants to merge 1 commit into
emco1234 wants to merge 1 commit into
Conversation
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
Contributor
|
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 Fixes anomalyco#28702 Co-Authored-By: OpenClaude (GLM-5.1) <openclaude@gitlawb.com>
f50dfc2 to
14a6c83
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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