playwright: [BUG] Har files recorded using webkit / chromium are missing postData information
System info
- Playwright Version: [v1.38.1 and older]
- Operating System: [Windows, MacOS]
- Browser: [Chromium, WebKit]
- Other info:
Source code
- I provided exact source code that allows reproducing the issue locally.
Code Example
context.routeFromHAR(this.harPath, {
update: true,
updateContent: 'embed'
});
Steps
- Setup a context with
routeFromHarfunction being called with the update flag - Run a test with one or more POST requests and a body using chromium or webkit
Expected
Har files should have postData value in the POST requests recorded as they do when using firefox. This helps in the future differentiate between POST requests with the same url when replaying the har functionality.
Resulting HAR generated using firefox
{
"method": "POST",
"url": ----?market=US&language=en-US&,
"httpVersion": "HTTP/2.0",
"cookies": [],
"headers": [
{ "name": ":authority", "value": ----},
{ "name": ":method", "value": "POST" },
{ "name": ":path", "value": ----?market=US&language=en-US& },
{ "name": ":scheme", "value": "https" },
{ "name": "accept", "value": "*/*" },
{ "name": "accept-encoding", "value": "gzip, deflate, br" },
{ "name": "accept-language", "value": "en-US" },
{ "name": "content-length", "value": "224" },
{ "name": "content-type", "value": "application/json" },
],
"queryString": [
{
"name": "market",
"value": "US"
},
{
"name": "language",
"value": "en-US"
},
],
"headersSize": -1,
"bodySize": -1,
"postData": {
"mimeType": "application/json",
"text": xxxx
"params": []
}
},
Actual
Har file has missing the postData value, if there are multiple POST requests to the same resource when replaying the har it will only resolve in the first one.
Resulting HAR generated using Chromium or webkit
{
"method": "POST",
"url": ----?market=US&language=en-US&,
"httpVersion": "HTTP/2.0",
"cookies": [],
"headers": [
{ "name": ":authority", "value": ----},
{ "name": ":method", "value": "POST" },
{ "name": ":path", "value": ----?market=US&language=en-US& },
{ "name": ":scheme", "value": "https" },
{ "name": "accept", "value": "*/*" },
{ "name": "accept-encoding", "value": "gzip, deflate, br" },
{ "name": "accept-language", "value": "en-US" },
{ "name": "content-length", "value": "224" },
{ "name": "content-type", "value": "application/json" },
],
"queryString": [
{
"name": "market",
"value": "US"
},
{
"name": "language",
"value": "en-US"
},
],
"headersSize": -1,
"bodySize": -1
},
Related Issues
Most likely it is due to something related to these issues, but i see them happening on normal ‘application/json’ payloads. request.postData() resolves to null when page uses fetch of FormData with a Blob #24077 Request object does not contain postData for file/blob #6479
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 15 (5 by maintainers)
This PR into Puppeteer looks relevant: https://github.com/puppeteer/puppeteer/pull/11598/commits/2125e312b3196df248cbf810e30ad6153e4c4f2c
Would this make sense to be ported over to Playwright?
FYI, this issue seems to have been solved in Chrome 125.0.6422.26? I cannot find any release notes from Chrome on that subject, but the Chrome version shipped in Playwright 1.44.0 now contains postData in recorded HARs.
Found a workaround for the clone issue that i uploaded to the example. An Init script with this code would get around that issue:
InitScript
This is not ideal because data is being saved twice but if it could be useful until the underlying bug is fixed.
I am still seeing the issue on my internal repository, but it should be due to another type of request modification that I am still trying to pin down.