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);