feat: add network command to browser-tools#11
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 25, 2026, 11:24 AM ET / 15:24 UTC. Summary Reproducibility: not applicable. this is a new CLI feature rather than a bug report. The PR body includes an inspected terminal GIF proving the new command emits real network events. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Merge the scoped command if maintainers want this browser-tools surface, with the maintainer-owned changelog entry handled at landing time. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a new CLI feature rather than a bug report. The PR body includes an inspected terminal GIF proving the new command emits real network events. Is this the best way to solve the issue? Yes: adding one Puppeteer event-stream command next to the existing console command is the narrowest maintainable path I saw. No duplicate built-in network capture command exists on current main. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against ab2f2a8de00e. Label changesLabel changes:
Label justifications:
Evidence reviewedWhat I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Summary
Agents driving the DevTools-attached Chrome from
browser-tools.tscan now tail network traffic the same way they tail console output.bun scripts/browser-tools.ts network --followprints[REQ ],[RESP], and[FAIL]lines as puppeteer reports them, with the same--port,--types,--follow,--timeout,--color,--no-colorflag set as the existingconsolesubcommand.Why this matters
console(PR #1) is the proven shape for tailing a CDP event stream from this script. Network traffic is the natural sibling event source: debugging XHR/fetch behavior currently means switching to another tool or running rawevalagainst the page. Mirroringconsolekeeps the surface symmetric and the implementation under ~125 lines.Resource-type filter accepts puppeteer's
resourceType()enum:document,stylesheet,image,media,font,script,xhr,fetch,manifest, plus a few less common values.websocketis intentionally omitted from the help example because puppeteer'srequestandresponseevents report only the WS upgrade handshake (frame traffic needs rawNetwork.webSocketFrameSent/Receivedvia CDP). The help description carries a one-liner for users who try--types websocketanyway.Output format:
[REQ ]cyan, method (6-wide), resourceType (9-wide), URL[RESP]status-colored (green 2xx, yellow 3xx, red 4xx/5xx), status (6-wide), resourceType (9-wide), URL, gray(Nms)duration[FAIL]red, method, resourceType, URL, red error reasonPer-request timing uses
WeakMap<HTTPRequest, number>keyed by the puppeteer request object, not URL+method, so parallel same-endpoint requests don't collide and the Map cleans up under--follow.Demo
Live capture from pre-PR smoke testing:
bun scripts/browser-tools.ts network --types document,script,image --timeout 3against a navigation tohttps://www.wikipedia.org/. 13 real network events.Testing
No automated test suite for
browser-tools.ts(consistent with the rest of the file). Manual smoke:bun scripts/browser-tools.ts start --port 9222 bun scripts/browser-tools.ts nav https://example.com bun scripts/browser-tools.ts network --types xhr,fetch --follow bun scripts/browser-tools.ts network --timeout 3 bun scripts/browser-tools.ts kill --ports 9222 --forceCHANGELOG entry left for maintainer copy on merge per AGENTS.MD ("Contributor PR authors should not edit changelog; maintainer/AI adds entry at merge"). Suggested line: