fix(qqbot): prevent busy-loop when WebSocket closes without exception - #27821
fix(qqbot): prevent busy-loop when WebSocket closes without exception#27821ygd58 wants to merge 1 commit into
Conversation
This PR (#27821) adds both pre-check AND post-check (raise after while loop exits cleanly with ws.closed=True), which is the missing piece in both. The post-check is what actually prevents the busy-loop in the 4009 session timeout scenario reported in #27810. |
|
CI triage: the two failing checks are not from the qqbot WebSocket change itself.
Root cause: branch is stale relative to current |
When ws.closed becomes True, _read_events() exits its while loop cleanly without raising an exception. _listen_loop() then immediately starts a new iteration with no sleep or reconnect delay, spinning at 100% CPU (issue NousResearch#27810). Fix: two guards in _read_events(): 1. Pre-check: raise immediately if ws is already closed on entry 2. Post-check: raise after loop exits cleanly with ws.closed=True Both cases surface as RuntimeError so _listen_loop's exception handler schedules a proper reconnect with exponential backoff instead of spinning. Fixes NousResearch#27810
19b332a to
e5863ee
Compare
|
BoardJames CI triage: the test failure is the same merged-state aux-config drift I reproduced on current main, not caused by this PR's changes. |
|
Thanks for the QQBot reconnect fix. This specific busy-loop issue has since been fixed on current Evidence:
Closing as implemented on main. |
Problem
When
ws.closedbecomes True,_read_events()exits its while loop cleanly without raising an exception._listen_loop()immediately starts a new iteration with no sleep or reconnect delay, spinning at 100% CPU.Fix
Two guards in
_read_events():ws.closed=TrueBoth surface as
RuntimeErrorso_listen_loopschedules proper reconnect with exponential backoff.Fixes #27810