From 1efa38e966fd4587f4580782e3237734151f951d Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Sat, 8 Apr 2023 20:15:16 +0200 Subject: [PATCH] Add better catch if getting the right page in the HAR fails. (#3810) --- lib/plugins/browsertime/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/plugins/browsertime/index.js b/lib/plugins/browsertime/index.js index 9560dd39d..0a73ae4ff 100644 --- a/lib/plugins/browsertime/index.js +++ b/lib/plugins/browsertime/index.js @@ -267,7 +267,20 @@ export default class BrowsertimePlugin extends SitespeedioPlugin { url ); } - run.har = pickAPage(result.har, harIndex); + try { + run.har = pickAPage(result.har, harIndex); + } catch (harError) { + log.error('Couldnt get the right page for the HAR', harError); + super.sendMessage( + 'error', + 'Could not get the right page for the HAR, the page is missing', + { + url, + runIndex, + iteration: runIndex + 1 + } + ); + } } else { // If we do not have a HAR, use browser info from the result if (result.length > 0) {