[kernel-1116] browser debug: add cdp monitor#202
[kernel-1116] browser debug: add cdp monitor#202archandatta wants to merge 13 commits intoarchand/kernel-1116/cdp-pipelinefrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0e65e19. Configure here.
| } | ||
| data, _ := json.Marshal(ev) | ||
| m.publishEvent(EventNetworkRequest, events.DetailStandard, events.Source{Kind: events.KindCDP}, "Network.requestWillBeSent", data, sessionID) | ||
| m.computed.onRequest() |
There was a problem hiding this comment.
Redirect requests double-increment netPending, blocking network_idle
High Severity
handleNetworkRequest unconditionally calls m.computed.onRequest() (incrementing netPending) for every Network.requestWillBeSent event. In CDP, HTTP redirects reuse the same requestId and fire additional requestWillBeSent events (with a redirectResponse field), but only a single loadingFinished fires per chain. The pendingRequests map correctly overwrites the entry, but netPending gets incremented again without a corresponding decrement. This permanently inflates netPending, preventing network_idle and navigation_settled from ever firing on pages with any HTTP redirects.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 0e65e19. Configure here.


Tests
curl -v -X POST http://localhost:444/events/startto start the event capture streamI did some browsing and started a yt video and got these logs from it:
network.log was the largest - open to thoughts on filtering some of it to reduce the size
(14), image/avif (14), image/x-icon (12), image/webp (1)
application/javascript (4)
Other skipped:
the body fetch returned empty or the resource type was filtered
What we ARE capturing bodies for (30 responses):
Note
Medium Risk
Adds a substantial new CDP WebSocket monitor (network/body capture, injected JS, timers, reconnect/backoff) and adjusts global
events.CategoryForparsing, which could affect event categorization across the pipeline.Overview
Introduces a full
cdpmonitorimplementation that connects to Chrome DevTools via WebSocket, auto-attaches to page targets (including pre-existing ones), enables key CDP domains, and injectsinteraction.jsto emit click/key/scroll events via a runtime binding.Adds event handlers that publish normalized events for console output/exceptions, navigation/DOM/page load, network requests/responses (optionally fetching and truncating textual bodies while skipping binary types), and layout shifts; plus computed meta-events (
network_idle,layout_settled,navigation_settled) driven by debounced timers.Implements lifecycle management with safe Start/Stop, in-flight command unblocking, and upstream-restart reconnection with backoff and
monitor_disconnected/monitor_reconnectedevents, and adds rate-limited screenshot capture viaffmpegwith downscaling to stay under size thresholds. Updatesevents.CategoryForto derive categories from underscore-delimited event types (and treatslayout_*as page events).Reviewed by Cursor Bugbot for commit 0e65e19. Bugbot is set up for automated code reviews on this repo. Configure here.