Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try/catch coach/third party tools errors #3957

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 49 additions & 42 deletions lib/plugins/browsertime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,51 +477,58 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {

// If the coach is turned on, collect the coach result
if (options.coach) {
const coachAdvice = browserScriptsData.coach.coachAdvice;
// check if the coach has error(s)
if (!isEmpty(coachAdvice.errors)) {
log.error(
'%s generated the following errors in the coach %:2j',
url,
coachAdvice.errors
);
super.sendMessage(
'error',
'The coach got the following errors: ' +
JSON.stringify(coachAdvice.errors),
{
try {
const coachAdvice = browserScriptsData.coach.coachAdvice;
// check if the coach has error(s)
if (!isEmpty(coachAdvice.errors)) {
log.error(
'%s generated the following errors in the coach %:2j',
url,
runIndex,
iteration: runIndex + 1
}
);
}
coachAdvice.errors
);
super.sendMessage(
'error',
'The coach got the following errors: ' +
JSON.stringify(coachAdvice.errors),
{
url,
runIndex,
iteration: runIndex + 1
}
);
}

let advice = coachAdvice;
// If we run without HAR
if (result.har) {
// make sure to get the right run in the HAR
const myHar = pickAPage(result.har, harIndex);

const harResult = await analyseHar(
myHar,
undefined,
coachAdvice,
options
);
advice = merge(coachAdvice, harResult);
}
const thirdPartyWebVersion = getThirdPartyWebVersion();
const wappalyzerVersion = getWappalyzerCoreVersion();
advice.thirdPartyWebVersion = thirdPartyWebVersion;
advice.wappalyzerVersion = wappalyzerVersion;
let advice = coachAdvice;
// If we run without HAR
if (result.har) {
// make sure to get the right run in the HAR
const myHar = pickAPage(result.har, harIndex);

const harResult = await analyseHar(
myHar,
undefined,
coachAdvice,
options
);
advice = merge(coachAdvice, harResult);
}
const thirdPartyWebVersion = getThirdPartyWebVersion();
const wappalyzerVersion = getWappalyzerCoreVersion();
advice.thirdPartyWebVersion = thirdPartyWebVersion;
advice.wappalyzerVersion = wappalyzerVersion;

super.sendMessage('coach.run', advice, {
url,
group,
runIndex,
iteration: runIndex + 1
});
super.sendMessage('coach.run', advice, {
url,
group,
runIndex,
iteration: runIndex + 1
});
} catch (error) {
// Lets be extra careful with coach and third party
// tools
super.sendMessage('error', error, _merge({ url }));
log.error('Caught error from the Coach', error);
}
}

this.browsertimeAggregator.addToAggregate(run, group);
Expand Down