Repository navigation
fix(tui): add retry backoff for event subscription to prevent CPU spin - #7468
SunandRiver wants to merge 2 commits into
Conversation
When the server shuts down, the TUI attach client enters a tight retry loop with 100% CPU usage because the event subscription loop lacks error handling and backoff. Changes: - Add try-catch around sdk.event.subscribe() - Implement exponential backoff: 1s → 2s → 4s → ... → 30s max - Add random jitter to prevent thundering herd - Give up after 10 consecutive failures with error message This prevents orphaned attach processes from spinning the CPU when their server has been terminated.
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
|
Hi @aidenpcline @maintainers, I noticed that the check is failing, but this appears to be due to a CI configuration issue rather than a problem with my code changes. Error details: Root cause: My PR status:
Suggested fix: Next steps from my side:
Thanks for looking into this! |
- Merge latest dev changes including props.events support - Apply retry backoff logic to SSE fallback - Maintain handleEvent architecture from upstream
|
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. |
|
Related issue: #7645 (TUI client CPU 100% when server shuts down) |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
Problem
When the server shuts down unexpectedly, the TUI attach client enters a tight retry loop causing 100% CPU usage. This happens because the event subscription loop in
sdk.tsxlacks error handling and backoff.Reproduction:
opencode spawnkill)Solution
sdk.event.subscribe()Testing
Manually tested by killing the server process and observing the attach client behavior - it now backs off exponentially and eventually exits gracefully instead of spinning the CPU.
Fixes #7645