Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(har): do not hang on chunked response in har recorder (#21397)
Yury Semikhatsky0ebe090b8c6e
diff --git a/packages/playwright-core/src/server/har/harTracer.ts b/packages/playwright-core/src/server/har/harTracer.tsindex 60a44ddf65..8629d6be31 100644--- a/packages/playwright-core/src/server/har/harTracer.ts+++ b/packages/playwright-core/src/server/har/harTracer.ts@@ -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);diff --git a/tests/library/har.spec.ts b/tests/library/har.spec.tsindex 5c66c83849..0a0e911f68 100644--- a/tests/library/har.spec.ts+++ b/tests/library/har.spec.ts@@ -831,7 +831,6 @@ it('should not hang on resources served from cache', async ({ contextFactory, seit('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',