Skip to content

Commit

Permalink
Send browsertime errors as early as possible (and fix some missing da…
Browse files Browse the repository at this point in the history
…ta) (#4475)
  • Loading branch information
soulgalore authored Mar 10, 2025
1 parent 85bddc9 commit 833e880
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions lib/plugins/browsertime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
// https://github.com/sitespeedio/sitespeed.io/issues/2341
for (const element of result) {
// Browsertime supports alias for URLS in a script
const alias = element.info.alias;
const alias = element.info?.alias;
if (alias) {
if (this.scriptOrMultiple) {
url = element.info.url;
Expand All @@ -207,14 +207,32 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
resultIndex++
) {
axeAggregatorPerURL = new AxeAggregator(this.options);
// Send errors from Browsertime as early as possible
// Check for errors. Browsertime errors is an array of all iterations
// [[],[],[]] where one iteration can have multiple errors
for (let errorsForOneIteration of result[resultIndex].errors) {
if (Array.isArray(errorsForOneIteration)) {
for (let error of errorsForOneIteration) {
super.sendMessage('error', error, _merge({ url }));
}
} else {
super.sendMessage(
'error',
`${errorsForOneIteration} ${result[resultIndex].failureMessages}`,
_merge({ url })
);
}
}
// If we use scripts or multiple, use the URL from the tested page
// so that we can handle click on links etc
// see https://github.com/sitespeedio/sitespeed.io/issues/2260
// we could change the plugins but since they do not work with
// multiple/scripting lets do it like this for now
if (this.scriptOrMultiple) {
url = result[resultIndex].info.url;
group = parse(url).hostname;
url = result[resultIndex].info?.url;
if (url) {
group = parse(url).hostname;
}
}
let runIndex = 0;
for (let browserScriptsData of result[resultIndex].browserScripts) {
Expand Down Expand Up @@ -597,14 +615,6 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
group
});
}

// Check for errors. Browsertime errors is an array of all iterations
// [[],[],[]] where one iteration can have multiple errors
for (let errorsForOneIteration of result[resultIndex].errors) {
for (let error of errorsForOneIteration) {
super.sendMessage('error', error, _merge({ url }));
}
}
}
break;
} catch (error) {
Expand Down

0 comments on commit 833e880

Please sign in to comment.