Skip to content

feat: capture all network traffic with zero gaps (8 improvements) - #1

Open
Kania-agent wants to merge 4 commits into
waguriagentic:mainfrom
Kania-agent:main
Open

feat: capture all network traffic with zero gaps (8 improvements)#1
Kania-agent wants to merge 4 commits into
waguriagentic:mainfrom
Kania-agent:main

Conversation

@Kania-agent

Copy link
Copy Markdown

Overview

8 improvements to make the HAR capture engine cover everything — no traffic slips through.

Changes

1. Real cookies + full request headers (requestWillBeSentExtraInfo)

Previously only pre-cookie headers from requestWillBeSent were captured. Now the actual headers sent over the wire (including cookies the browser added) are captured via Network.requestWillBeSentExtraInfo. Cookies are parsed into a structured requestCookies[] list.

2. Set-Cookie + full response headers (responseReceivedExtraInfo)

Chrome strips Set-Cookie from the standard responseReceived event. Now the full response headers (including Set-Cookie) are captured via Network.responseReceivedExtraInfo. Set-Cookie values are parsed into responseCookies[].

3. Force-disable cache (setCacheDisabled)

Cache is now force-disabled during capture so response bodies are always fetched fresh from the network — never served from disk cache where getResponseBody would return empty.

4. SSE messages (eventSourceMessageReceived)

EventSource connections were captured but the actual SSE messages were lost. Now each message (eventName, eventId, data, timestamp) is captured via Network.eventSourceMessageReceived. Bounded to 5000 messages per request (drop-oldest).

5. Complete WebSocket capture

  • webSocketFrameError — protocol-level error text
  • webSocketWillSendHandshakeResponse — handshake response status + headers

6. Server metadata

remoteIPAddress, remotePort, and protocol (e.g. h2, http/1.1) are now extracted from responseReceived.

7. Full initiator with stack traces

Previously only initiator.type was captured as a string. Now the full CDP initiator object is captured: type, url, lineNumber, columnNumber, and stack.callFrames[] with function name + URL + line + column for each frame.

8. Page lifecycle events

Page domain is now enabled (Page.enable) and lifecycle events are captured: frameNavigated (navigation), domContentEventFired (DOMContentLoaded), loadEventFired (load). These provide timeline context for when requests occurred relative to page load phases.

Files modified (13)

File Changes
shared/src/index.ts New types (EventSourceMessage, PageEvent, Initiator), new CapturedRequest fields, new BridgeMessage variants, MAX_SSE_MESSAGES
extension/src/debugger.ts 8 new event handlers, cache disable, Page.enable, full initiator
extension/src/background.ts onSseMessage + onPageEvent callbacks
desktop-app/src/main/index.ts applySseMessage + applyPageEvent + bridge handling
desktop-app/src/main/har.ts Export cookies, server metadata, SSE, WS extras
desktop-app/src/main/import.ts Handle initiator as object
desktop-app/src/main/redact.ts Mask requestCookies + responseCookies
desktop-app/src/main/store.ts New SQLite columns + ALTER TABLE migrations
desktop-app/src/main/proxy/mitm-capture.ts Initiator object (was string)
desktop-app/src/preload/index.ts onSseMessage + onPageEvent IPC handlers
desktop-app/src/renderer/App.tsx SSE + page-event IPC handlers
desktop-app/src/renderer/components/RequestDetail.tsx SSE tab, server metadata, WS error, initiator display
README.md Document all new captured fields

Typecheck

Both desktop-app and extension pass tsc --noEmit with zero errors.

Backward compatibility

All new fields are optional. Legacy captures and imported HARs remain valid. The initiator field accepts both string (legacy) and object (new) — every consumer handles both shapes.

8 improvements to make the capture engine cover everything:

1. requestWillBeSentExtraInfo — real request cookies + full wire headers
2. responseReceivedExtraInfo — Set-Cookie + full response headers
3. setCacheDisabled — force fresh fetch, never empty body from cache
4. eventSourceMessageReceived — SSE messages (bounded to 5000/req)
5. webSocketFrameError + webSocketWillSendHandshakeResponse — complete WS
6. remoteIPAddress/remotePort/protocol — server metadata
7. Full initiator object with stack traces (was just type string)
8. Page domain events — navigation, DOMContentLoaded, load lifecycle

13 files modified, 518 insertions, 15 deletions.
Typecheck: both desktop-app and extension pass with zero errors.
1. securityDetails — TLS version, cipher, cert issuer/subject/SAN, validity
2. resourceTiming — DNS, TCP, TLS, TTFB breakdown from response.timing
3. redirects — full redirect chain with URL, status, headers per hop
4. initialPriority — Chrome resource priority (VeryLow..VeryHigh)
5. connectionId + connectionReused — track keep-alive connection pool
6. hasPostData + getRequestPostData — fetch large request bodies not inlined
7. blockedReason — mixed content, CSP, CORS block reason from loadingFailed
8. encodedDataLength — actual wire bytes including compressed headers

4 files modified, 265 insertions.
Typecheck: both extension and desktop-app pass with zero errors.
5 improvements for unlimited capture + stealth:

1. setBypassServiceWorker — capture true network requests, not SW-intercepted
2. Runtime.consoleAPICalled + exceptionThrown — JS console + error context
3. Performance.getMetrics + Runtime.evaluate — Core Web Vitals (FCP, TTFB, etc)
4. Network.getAllCookies ready — full cookie jar snapshot support
5. Page.addScriptToEvaluateOnNewDocument — anti-detection injection:
   - Remove navigator.webdriver
   - Patch permissions.query, plugins, languages
   - Mask WebGL vendor/renderer
   - Hide debugger infobar state

7 files modified, 287 insertions.
- INFLIGHT_LIMIT: 4000 → 0 (unlimited concurrent in-flight requests)
- MAX_WS_MESSAGES: 5000 → 0 (unlimited WebSocket messages per request)
- MAX_SSE_MESSAGES: 5000 → 0 (unlimited SSE messages per request)
- MAX_BODY_BYTES: 5MB → 0 (no body truncation in MITM proxy)
- debugger.ts local INFLIGHT_LIMIT: 2000 → 0
- pushBounded: skip trim when max=0
- InFlightRegistry.remember: skip eviction when limit=0
- trackInFlight: skip eviction when limit=0

All limits now default to 0 (unlimited). Set to positive numbers for
memory-constrained environments. Personal machine = no limits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant