record "blocked"

This commit is contained in:
Simon Knott 2024-10-14 12:02:22 +02:00
parent 15414fb59e
commit a14a7d2837
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 4 additions and 0 deletions

View file

@ -302,6 +302,7 @@ export abstract class APIRequestContext extends SdkObject {
const requestOptions = { ...options, agent }; const requestOptions = { ...options, agent };
const startAt = monotonicTime(); const startAt = monotonicTime();
let reusedSocketAt: number | undefined;
let dnsLookupAt: number | undefined; let dnsLookupAt: number | undefined;
let tcpConnectionAt: number | undefined; let tcpConnectionAt: number | undefined;
let tlsHandshakeAt: number | undefined; let tlsHandshakeAt: number | undefined;
@ -330,6 +331,7 @@ export abstract class APIRequestContext extends SdkObject {
}; };
if (request.reusedSocket) { if (request.reusedSocket) {
timings.blocked = reusedSocketAt! - startAt;
timings.connect = -1; timings.connect = -1;
timings.dns = -1; timings.dns = -1;
} }
@ -497,6 +499,7 @@ export abstract class APIRequestContext extends SdkObject {
// happy eyeballs don't emit lookup and connect events, so we use our custom ones // happy eyeballs don't emit lookup and connect events, so we use our custom ones
const happyEyeBallsTimings = timingForSocket(socket); const happyEyeBallsTimings = timingForSocket(socket);
if (request.reusedSocket) { if (request.reusedSocket) {
reusedSocketAt = monotonicTime();
dnsLookupAt = startAt; dnsLookupAt = startAt;
tcpConnectionAt = startAt; tcpConnectionAt = startAt;
} else { } else {

View file

@ -887,6 +887,7 @@ it('should not have connect and dns timings when socket is reused', async ({ con
const request2 = log.entries[1]; const request2 = log.entries[1];
expect.soft(request2.timings.connect).toBe(-1); expect.soft(request2.timings.connect).toBe(-1);
expect.soft(request2.timings.dns).toBe(-1); expect.soft(request2.timings.dns).toBe(-1);
expect.soft(request2.timings.blocked).toBeGreaterThan(0);
}); });
it('should include redirects from API request', async ({ contextFactory, server }, testInfo) => { it('should include redirects from API request', async ({ contextFactory, server }, testInfo) => {