readable and data are mutually exclusive
This commit is contained in:
parent
513b1c2ab3
commit
7e2acc513d
|
|
@ -319,8 +319,6 @@ export abstract class APIRequestContext extends SdkObject {
|
||||||
let endAt: number | undefined;
|
let endAt: number | undefined;
|
||||||
|
|
||||||
const request = requestConstructor(url, requestOptions as any, async response => {
|
const request = requestConstructor(url, requestOptions as any, async response => {
|
||||||
response.once('readable', () => { firstByteAt = monotonicTime(); });
|
|
||||||
|
|
||||||
const notifyRequestFinished = (body?: Buffer) => {
|
const notifyRequestFinished = (body?: Buffer) => {
|
||||||
const timings: har.Timings = {
|
const timings: har.Timings = {
|
||||||
send: requestFinishAt! - startAt,
|
send: requestFinishAt! - startAt,
|
||||||
|
|
@ -476,7 +474,10 @@ export abstract class APIRequestContext extends SdkObject {
|
||||||
body.on('error', reject);
|
body.on('error', reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
body.on('data', chunk => chunks.push(chunk));
|
body.on('data', chunk => {
|
||||||
|
firstByteAt ??= monotonicTime();
|
||||||
|
chunks.push(chunk);
|
||||||
|
});
|
||||||
body.on('end', notifyBodyFinished);
|
body.on('end', notifyBodyFinished);
|
||||||
});
|
});
|
||||||
request.on('error', error => reject(rewriteOpenSSLErrorIfNeeded(error)));
|
request.on('error', error => reject(rewriteOpenSSLErrorIfNeeded(error)));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue