fix(browser): bound CDP reconnect loop to prevent infinite retry on 502/503 - #44460
fix(browser): bound CDP reconnect loop to prevent infinite retry on 502/503#44460plcunha wants to merge 2 commits into
Conversation
Verification: CDP reconnect bound looks solidReviewed the full diff. The implementation is well-structured:
No issues found. The bound prevents the infinite reconnect loop documented in the PR title. |
Verified against main (8505e9d) — bug is real; fix direction is right; the 502 detection has demonstrable false positivesConfirmed:
Issues:
|
check-attribution flagged emails introduced by the bugfixes rollup: AIalliAI's three commit emails and plcunha's (cherry-picked PR NousResearch#44460). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for targeting a real stall: current main still has an unbounded post-ready reconnect path in Problems
Suggested changes
This is an automated hermes-sweeper review. |
|
Thanks — I agree with the concerns and addressed them in The status-substring classifier has been removed. The reconnect budget now covers every failed reconnect cycle after initial readiness:
A successful socket connection no longer resets the counter. The streak resets only after the session has remained attached for a 30-second stability window; the subsequent drop starts a new streak at 1. Endpoint/error redaction is preserved on all reconnect logs, and the supervisor thread's crash log now uses the same redaction helper as well. I added regression tests for bounded attach failures, bounded quick session drops, stable-session reset behavior, positive budget validation, and secret redaction. Local verification: 25 tests passed across the reconnect-budget, health-check, and secret-exfiltration suites; the new test also passes Would appreciate a re-review when convenient. |
The CDP supervisor's _run() reconnect loop had no upper bound — it retried WebSocket connections forever, even when the upstream service (Browserbase) returned HTTP 502/503 (infrastructure failures). This caused multi-minute stalls when the browser session died: - 19 retries × ~11s each = ~3.5 min wasted - Context grew until compressor also timed out (cascade failure) Changes: - Added max_reconnect_attempts (default 10) to CDPSupervisor - Treat HTTP 502/503/Service Unavailable/Bad Gateway as immediately fatal - Reset consecutive_failures after successful connection - Log level ERROR (not WARNING) when giving up - Improved log message to show attempt count vs max
1e18717 to
c088f0e
Compare
c088f0e to
15459fb
Compare
Problem
The CDP supervisor's
_run()reconnect loop had no upper bound — it retried WebSocket connections forever, even when the upstream service (Browserbase) returned HTTP 502/503 (infrastructure failures).This caused multi-minute stalls when a browser session died:
Root cause
_run()at line 614 usedwhile not self._stop_requestedwith no max retries, no infrastructure failure detection, and no circuit breaker. This was designed to survive transient WebSocket drops (Browserbase tearing down CDP sockets between commands) — but it treated persistent infrastructure failures identically to transient ones.Fix
max_reconnect_attempts(default 10) toCDPSupervisorconsecutive_failureson successful connection (so transient drops still work)attempt 12/10instead of justattempt 12)Testing
Manual verification on a live instance that hit this bug: