question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Recording actual values in HAR file / recordHar

See original GitHub issue

recordHar is a great option for analyzing and debugging HTTP requests and responses, especially since there doesn’t seem to be browser support for generating HAR files via the command-line.

There seem to be several placeholder values in the resulting HAR file as generated by harTracer.ts. For example, HTTP version is always set to HTTP/1.1, and other fields are always set to -1:

https://github.com/microsoft/playwright/blob/da1dafcadb05fd648f13610d8eefc4baa5c2261e/src/server/supplements/har/harTracer.ts#L151-L164

It seems like many (if not all?) of the placeholder values could be replaced with the actual values from network.Request and network.Response: is there any reason why that wouldn’t work? Are there any particular cross-platform or cross-browser issues to consider?

I’m implementing this feature for my own use and more than happy to push it upstream for review and feedback.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mxschmittcommented, Aug 24, 2021

Closing since HAR has now more sizes, httpVersion, etc. Please create a new issue which fields are exactly missing, thanks!

0reactions
tnoletcommented, May 3, 2021

@cardi @dgozman just hopping in here to show interest. Mostly the size properties are very relevant to many use cases with the HAR file, e.g.

   content: { 
     size: -1, 
     mimeType: 'foo'
   }, 
   headersSize: -1, 
   bodySize: -1, 

Having these values as -1 prohibits analyses on, well, file and transfer sizes. Will have a stab at providing a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use HAR Files to Analyze Performance Over Time
Go to View > Developer > Developers Tools. In the Developer Tools panel, choose the Network tab. Check the Preserve Log and Disable...
Read more >
Unable to record HAR with Playwright .NET - Stack Overflow
I am trying to record a HAR file with Playwright. According to the docs, all you need to do is pass RecordHarPath in...
Read more >
Browser | Playwright
Emulates 'prefers-colors-scheme' media feature, supported values are 'light' , 'dark' ... Enables HAR recording for all pages into recordHar.path file.
Read more >
Generating HAR files and analyzing web requests
Go to Developer tools and choose "Start Timeline Recording". Select timeline all instruments to record. Refresh the page to start capturing the ...
Read more >
allow saving har for context (#4214) · 7fc4b797eb - playwright
`recordHar` <[Object]> Enables [HAR](http://www.softwareishard.com/blog/har-12-spec) recording for all pages into `har.path` file. If not specified, the HAR ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found