feat(cdp): implement session-level network capture for CDPPage#815
Merged
feat(cdp): implement session-level network capture for CDPPage#815
Conversation
Implements startNetworkCapture() and readNetworkCapture() on CDPPage using CDP Network domain events. Updates explore.ts to prefer session capture over Performance API networkRequests(). Closes part of #810
- Move getResponseBody call from responseReceived to loadingFinished, matching the extension's implementation pattern - Use extension-compatible entry shape (responseStatus, responseContentType, responsePreview) instead of custom field names - Remove unreliable 100ms sleep hack in readNetworkCapture() - Align with extension/src/cdp.ts:419-437 for consistency
readNetworkCapture() must clear the buffer after reading, matching the daemon Page's read-and-drain behavior. Without this, repeated reads would return stale entries.
…orkCapture Track all pending getResponseBody promises and await them in readNetworkCapture() before draining the buffer. This ensures explore/diagnostic consumers always get entries with responsePreview populated, not empty shells where the body fetch hasn't resolved yet.
4 tasks
parseNetworkRequests now maps both shapes: - Legacy: status, contentType, responseBody - Capture (extension/CDP): responseStatus, responseContentType, responsePreview Also clears _pendingBodyFetches on startNetworkCapture reset.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
startNetworkCapture()andreadNetworkCapture()on CDPPage using CDP Network domain eventsexplore.tsto prefer session capture over Performance APInetworkRequests()Details
CDPPage changes (
src/browser/cdp.ts):startNetworkCapture(pattern?): enablesNetwork.enable, listens toNetwork.requestWillBeSentandNetwork.responseReceived, collects full request/response data including response bodies viaNetwork.getResponseBodyreadNetworkCapture(): returns collected entries and clears bufferExplore changes (
src/explore.ts):page.startNetworkCapture?.()beforepage.goto()to capture initial page load requestspage.readNetworkCapture()overpage.networkRequests()when available, with fallbackWhy this matters
explore previously used
networkRequests()which only returns URL+timing from the Performance API. With session capture, explore gets method/status/headers/body — enabling much better API endpoint discovery and candidate generation.Test plan
opencli explore <url>with CDP endpoint should capture full network dataPart of #810 (PR A)