refactor endAt

This commit is contained in:
Simon Knott 2024-09-16 10:07:57 +02:00
parent 5d8ab8a33c
commit dde4488ebb
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -315,11 +315,11 @@ export abstract class APIRequestContext extends SdkObject {
let tcpConnectionAt: number | undefined;
let tlsHandshakeAt: number | undefined;
let requestFinishAt: number | undefined;
let endAt: number | undefined;
const request = requestConstructor(url, requestOptions as any, async response => {
const responseAt = monotonicTime();
const notifyRequestFinished = (body?: Buffer) => {
const endAt = monotonicTime();
// spec: http://www.softwareishard.com/blog/har-12-spec/#timings
const timings: har.Timings = {
send: requestFinishAt! - startAt,
@ -435,7 +435,6 @@ export abstract class APIRequestContext extends SdkObject {
const chunks: Buffer[] = [];
const notifyBodyFinished = () => {
endAt = monotonicTime();
const body = Buffer.concat(chunks);
notifyRequestFinished(body);
fulfill({