diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.ts index c4e5f2198d..0c2f4945b9 100644 --- a/packages/playwright-core/src/server/fetch.ts +++ b/packages/playwright-core/src/server/fetch.ts @@ -508,6 +508,10 @@ export abstract class APIRequestContext extends SdkObject { } }); + // when using socks proxy, having the socket means the connection got established + if (agent instanceof SocksProxyAgent) + tcpConnectionAt ??= monotonicTime(); + serverIPAddress = socket.remoteAddress; serverPort = socket.remotePort; }); diff --git a/tests/library/har.spec.ts b/tests/library/har.spec.ts index 1d8dbf55a1..3a10347825 100644 --- a/tests/library/har.spec.ts +++ b/tests/library/har.spec.ts @@ -868,8 +868,7 @@ it('should include timings when using http proxy', async ({ contextFactory, serv expect(log.entries[0].timings.connect).toBeGreaterThan(0); }); -// socks proxy library doesnt emit an event to know when the TCP connection starts -it.fail('should include timings when using socks proxy', async ({ contextFactory, server, socksPort }, testInfo) => { +it('should include timings when using socks proxy', async ({ contextFactory, server, socksPort }, testInfo) => { const { page, getLog } = await pageWithHar(contextFactory, testInfo, { proxy: { server: `socks5://localhost:${socksPort}` } }); const response = await page.request.get(server.EMPTY_PAGE); await response.body();