fix(har): do not hang on chunked response in har recorder (#21397)

Fixes #21182
This commit is contained in:
Yury Semikhatsky 2023-03-03 17:27:34 -08:00 committed by GitHub
parent 0c5d46bb94
commit 0ebe090b8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 15 deletions

View File

@ -289,6 +289,23 @@ export class HarTracer {
return;
const page = request.frame()?._page;
// In WebKit security details and server ip are reported in Network.loadingFinished, so we populate
// it here to not hang in case of long chunked responses, see https://github.com/microsoft/playwright/issues/21182.
if (!this._options.omitServerIP) {
this._addBarrier(page || request.serviceWorker(), response.serverAddr().then(server => {
if (server?.ipAddress)
harEntry.serverIPAddress = server.ipAddress;
if (server?.port)
harEntry._serverPort = server.port;
}));
}
if (!this._options.omitSecurityDetails) {
this._addBarrier(page || request.serviceWorker(), response.securityDetails().then(details => {
if (details)
harEntry._securityDetails = details;
}));
}
const httpVersion = response.httpVersion();
harEntry.request.httpVersion = httpVersion;
harEntry.response.httpVersion = httpVersion;
@ -435,20 +452,6 @@ export class HarTracer {
this._computeHarEntryTotalTime(harEntry);
}
if (!this._options.omitServerIP) {
this._addBarrier(page || request.serviceWorker(), response.serverAddr().then(server => {
if (server?.ipAddress)
harEntry.serverIPAddress = server.ipAddress;
if (server?.port)
harEntry._serverPort = server.port;
}));
}
if (!this._options.omitSecurityDetails) {
this._addBarrier(page || request.serviceWorker(), response.securityDetails().then(details => {
if (details)
harEntry._securityDetails = details;
}));
}
this._recordRequestOverrides(harEntry, request);
this._addBarrier(page || request.serviceWorker(), request.rawRequestHeaders().then(headers => {
this._recordRequestHeadersAndCookies(harEntry, headers);

View File

@ -831,7 +831,6 @@ it('should not hang on resources served from cache', async ({ contextFactory, se
it('should not hang on slow chunked response', async ({ browserName, browser, contextFactory, server }, testInfo) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21182' });
it.fixme(browserName === 'webkit');
server.setRoute('/empty.html', (req, res) => {
res.writeHead(200, {
'Content-Type': 'text/html',