From 957fe5220ba91bd4ca1b16e3692af3d354cdd7b4 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Sat, 23 Nov 2024 19:51:26 +0100 Subject: [PATCH] fix: use compare with --cpu for Firefox failed. (#4324) This catches if we got no longtask information. --- lib/plugins/compare/helper.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/plugins/compare/helper.js b/lib/plugins/compare/helper.js index 2653cd7085..88e34c9d81 100644 --- a/lib/plugins/compare/helper.js +++ b/lib/plugins/compare/helper.js @@ -275,16 +275,18 @@ function getCPU(data) { }; for (const run of data.cpu) { - const longTasks = run.longTasks; - cpuMetrics['tasks'].push(longTasks['tasks']); - cpuMetrics['totalDuration'].push(longTasks['totalDuration']); - cpuMetrics['lastLongTask'].push(longTasks['lastLongTask']); - cpuMetrics['beforeFirstContentfulPaint'].push( - longTasks['beforeFirstContentfulPaint'].totalDuration - ); - cpuMetrics['beforeLargestContentfulPaint'].push( - longTasks['beforeLargestContentfulPaint'].totalDuration - ); + if (run.longTasks) { + const longTasks = run.longTasks; + cpuMetrics['tasks'].push(longTasks['tasks']); + cpuMetrics['totalDuration'].push(longTasks['totalDuration']); + cpuMetrics['lastLongTask'].push(longTasks['lastLongTask']); + cpuMetrics['beforeFirstContentfulPaint'].push( + longTasks['beforeFirstContentfulPaint'].totalDuration + ); + cpuMetrics['beforeLargestContentfulPaint'].push( + longTasks['beforeLargestContentfulPaint'].totalDuration + ); + } } const isEmpty = Object.values(cpuMetrics).every(arr => arr.length === 0);