fix(#124): HAR recording returns 0 entries - add response_body via getResponseBody - #127
fix(#124): HAR recording returns 0 entries - add response_body via getResponseBody#127lekt9 wants to merge 1 commit into
Conversation
…seBody Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
justrach
left a comment
There was a problem hiding this comment.
Review
Good addition — response bodies are the missing piece in our HAR capture. The implementation is clean. A few suggestions:
✅ What's good
request_idandresponse_bodyfields properly owned/duped/freedfetchResponseBodies()is a clean post-processing step- Existing tests updated with new fields
⚠️ Suggestions
-
Filter response bodies — Currently
fetchResponseBodies()fetches bodies for ALL entries indiscriminately. PR #122 had a smarter filter that's worth adopting:// Skip non-useful responses if (entry.status < 200 or entry.status >= 400) continue; if (std.mem.endsWith(u8, entry.url, ".js") or std.mem.endsWith(u8, entry.url, ".css")) continue; // Only fetch JSON, HTML, plain text if (std.mem.indexOf(u8, entry.mime_type, "json") == null and std.mem.indexOf(u8, entry.mime_type, "text/html") == null and std.mem.indexOf(u8, entry.mime_type, "text/plain") == null) continue;
Without filtering, a page with 50+ entries (images, fonts, CSS, JS) will make 50+ serial CDP calls, adding significant latency to
/har/stop. -
Duplicate doc comments — There are doubled
/// Add a manually observed request/responseand/// Serialize current entries to HAR 1.2 JSON format.comments in har.zig. Remove the duplicates. -
response_body type — You use
[]const u8(always allocated). PR #122 used?[]const u8(optional) which is cleaner — only allocate when we actually have a body. This avoids allocating empty strings for entries where we skip body fetch. -
Rebase needed —
har.zigon main now hasOwnedEventstruct changes and different field layout. Should be a straightforward rebase.
🔧 After addressing
This is good to merge once the filtering and optional body type are in.
|
Can you update this PR to build and test against Zig |
|
Re-reading this against current
If you'd rather just land the cross-arena fix now (which is uncontroversial) and split the response-body capture into its own PR, I'd merge the EventBuffer part today. |
Adds request_id and response_body fields to HarEntry. New fetchResponseBodies helper loops entries after event flush, calls Network.getResponseBody for each, stores body. handleHarStop wires this in before final serialisation. All 17 har+client tests pass.