From 29a1d9880c4616a10c38eca77f92c58e4d49429e Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Mon, 3 Mar 2025 16:03:24 +0100 Subject: [PATCH] Make sure sitespeed.io do not fail if a test fails. https://github.com/sitespeedio/sitespeed.io/issues/4453 https://github.com/sitespeedio/sitespeed.io/pull/4454 --- lib/plugins/pagexray/index.js | 20 +++++++++++--------- lib/plugins/pagexray/pagexrayAggregator.js | 3 ++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/plugins/pagexray/index.js b/lib/plugins/pagexray/index.js index 8f19ce11c..05e18edf5 100644 --- a/lib/plugins/pagexray/index.js +++ b/lib/plugins/pagexray/index.js @@ -128,15 +128,17 @@ export default class PageXrayPlugin extends SitespeedioPlugin { ); } } else { - pageSummary[0].statistics = this.pageXrayAggregator.summarizePerUrl( - message.url - ); - queue.postMessage( - make('pagexray.pageSummary', pageSummary[0], { - url: message.url, - group // TODO get the group from the URL? - }) - ); + // Check that we actually have one tested page + if (pageSummary.length > 0) { + pageSummary[0].statistics = + this.pageXrayAggregator.summarizePerUrl(message.url); + queue.postMessage( + make('pagexray.pageSummary', pageSummary[0], { + url: message.url, + group // TODO get the group from the URL? + }) + ); + } let iteration = 1; for (let summary of pageSummary) { queue.postMessage( diff --git a/lib/plugins/pagexray/pagexrayAggregator.js b/lib/plugins/pagexray/pagexrayAggregator.js index 1a4b8145f..041a3ade0 100644 --- a/lib/plugins/pagexray/pagexrayAggregator.js +++ b/lib/plugins/pagexray/pagexrayAggregator.js @@ -140,7 +140,8 @@ export class PageXrayAggregator { } } summarizePerUrl(url) { - return this.summarizePerObject(this.urls[url]); + // If we do not have a tested working page there's nothing to summarize + return this.urls[url] ? this.summarizePerObject(this.urls[url]) : {}; } summarize() { if (Object.keys(this.stats).length === 0) {