From 3662ef14eac8cfcc6d1b274711d212c8001528e3 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Mon, 30 Dec 2024 05:41:28 +0100 Subject: [PATCH] Add safe checks (#4379) --- .../browsertime/browsertimeAggregator.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/plugins/browsertime/browsertimeAggregator.js b/lib/plugins/browsertime/browsertimeAggregator.js index 7d7a063de1..4156193c40 100644 --- a/lib/plugins/browsertime/browsertimeAggregator.js +++ b/lib/plugins/browsertime/browsertimeAggregator.js @@ -234,16 +234,20 @@ export class BrowsertimeAggregator { summary.userTimings = {}; const marksData = {}, measuresData = {}; - for (const [timingName, stats] of Object.entries( - object.userTimings.marks - )) { - setStatsSummary(marksData, timingName, stats); + if (object.userTimings.marks) { + for (const [timingName, stats] of Object.entries( + object.userTimings.marks + )) { + setStatsSummary(marksData, timingName, stats); + } } - for (const [timingName, stats] of Object.entries( - object.userTimings.measures - )) { - setStatsSummary(measuresData, timingName, stats); + if (object.userTimings.measures) { + for (const [timingName, stats] of Object.entries( + object.userTimings.measures + )) { + setStatsSummary(measuresData, timingName, stats); + } } summary.userTimings.marks = marksData; @@ -253,8 +257,10 @@ export class BrowsertimeAggregator { const categories = {}; summary.cpu = {}; - for (const [name, stats] of Object.entries(object.cpu.longTasks)) { - setStatsSummary(longTasks, name, stats); + if (object.cpu.longTasks) { + for (const [name, stats] of Object.entries(object.cpu.longTasks)) { + setStatsSummary(longTasks, name, stats); + } } if (object.cpu.categories) {