Repository navigation
fix(browser): bound CDP output for stalled clients - #20949
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one minor docs-tracking nit.
Reviewed changes
- Backpressure routing for CDP replies:
CdpClientResponseWriter.sendnow enqueues onto the existingcreateWsOutboundBackpressureQueue(8 MiB soft cap, 64 MiB / 4,096-frame hard caps) instead of writing straight tows, with lazy per-client queue creation and disposal inforgetClient. - Debugger events share that queue:
CdpDebuggerChannelevent fan-out now callsresponder.send(msg, client)instead ofclient.send(...), so events and command replies preserve order through one queue. Event payloads carry no numericid, so the responder's session-correlation step is a no-op for them. - Tests + audit artifacts: a new real-socket writer suite pins ordering/session correlation, queue teardown, stalled-reader termination on overflow, and a 65 MiB single reply;
docs/audits/cdp-stream-retention/records the before/after reproduction.
ℹ️ Nitpicks
docs/audits/cdp-stream-retention/matches the wholesaledocs/**ignore rule (.gitignore:96) and was force-added, so a cleangit addwon't pick it up. Add!docs/audits/and!docs/audits/**to the allow-list so the evidence stays reproducible.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe CDP response writer now queues serialized WebSocket messages per client. The queue reports overflow evidence, limits draining per event-loop turn, terminates stalled clients, and disposes state when clients close or are forgotten. Debugger events use this writer. Tests cover ordering, cleanup, large replies, stalled readers, and bursts. Audit tooling and fixtures measure retention behavior. Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The outbound queue terminated the automation client silently on overflow, so the client saw a socket close indistinguishable from a crash. Surface the cap that tripped and the backlog held when it did. The queue dropped its backlog before invoking onOverflow, so the counters were already zero at the callback. Snapshot them first and pass them through.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the single commit added since the prior pullfrog review (d12d1e0 → c1ff3b7), which adds observability to the CDP outbound overflow path.
- Overflow evidence on the shared queue:
createWsOutboundBackpressureQueue'sonOverflownow receives aWsOutboundOverflowEvidencesnapshot — which cap tripped plus the backlog held when it did — captured beforedropBacklog()zeroes the counters. The widened signature is backward compatible; every existing caller passes a zero-arg handler. - CDP overflow logging:
CdpClientResponseWriterlogs the cap and queued byte/frame counts before terminating a stalled automation client, so the abrupt close is diagnosable from the main-process log.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Browser automation clients receive command replies and browser events. If a client stops reading, Orca previously kept saving more messages for it. This change disconnects a client whose waiting messages become too large.
What Changed
Send CDP output through the existing bounded WebSocket writer. A stalled connection is terminated when queued output exceeds 64 MiB or 4,096 frames. Normal replies and events retain their order.
Why
One stalled automation client should not exhaust the host's memory. Keeping every message forever recreates the leak.
Tradeoff
Queued replies and events are discarded when the connection is closed. Automation may need to reconnect and determine whether a command already ran before retrying it. Large direct messages remain allowed while the connection is draining.
Linked Issue
Related to #19831 as memory hardening; incident causality is not established.
Visual Proof
No before/after UI capture is attached; this is an automation-connection behavior change. Automated behavior evidence is linked under Testing.
Testing
The audit covers a stalled real client, both queue limits, close cleanup, and ordinary CDP output delivery.
Audit evidence
Review
Do not automatically retry side-effecting commands unless the caller can prove they are idempotent.