Guard against no pages in the HAR (#4430)

This commit is contained in:
Peter Hedenskog 2025-02-05 10:04:54 +01:00 committed by GitHub
parent 5abff0c5ae
commit 65e3751a9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 30 deletions

View File

@ -80,40 +80,45 @@ export class DomainsAggregator {
if (this.groups[mainDomain] === undefined) {
this.groups[mainDomain] = {};
}
const firstPageId = har.log.pages[0].id;
for (const entry of har.log.entries) {
if (entry.pageref !== firstPageId) {
// Only pick the first request out of multiple runs.
continue;
}
if (har.log.pages.length > 0) {
const firstPageId = har.log.pages[0].id;
const domainName = parseDomainName(entry.request.url),
domain = this.domains[domainName] || getDomain(domainName),
groupDomain =
this.groups[mainDomain][domainName] || getDomain(domainName),
totalTime = entry.time;
domain.requestCount++;
groupDomain.requestCount++;
if (isValidTiming(totalTime)) {
domain.totalTime.push(totalTime);
groupDomain.totalTime.push(totalTime);
} else {
log.debug('Missing time from har entry for url: ' + entry.request.url);
}
for (const name of timingNames) {
const timing = entry.timings[name];
if (isValidTiming(timing)) {
domain[name].push(timing);
groupDomain[name].push(timing);
for (const entry of har.log.entries) {
if (entry.pageref !== firstPageId) {
// Only pick the first request out of multiple runs.
continue;
}
const domainName = parseDomainName(entry.request.url),
domain = this.domains[domainName] || getDomain(domainName),
groupDomain =
this.groups[mainDomain][domainName] || getDomain(domainName),
totalTime = entry.time;
domain.requestCount++;
groupDomain.requestCount++;
if (isValidTiming(totalTime)) {
domain.totalTime.push(totalTime);
groupDomain.totalTime.push(totalTime);
} else {
log.debug(
'Missing time from har entry for url: ' + entry.request.url
);
}
for (const name of timingNames) {
const timing = entry.timings[name];
if (isValidTiming(timing)) {
domain[name].push(timing);
groupDomain[name].push(timing);
}
}
this.domains[domainName] = domain;
this.groups[mainDomain][domainName] = groupDomain;
}
this.domains[domainName] = domain;
this.groups[mainDomain][domainName] = groupDomain;
}
}
summarize() {