diff --git a/src/core/runner.ts b/src/core/runner.ts index fd04ba9e..49abbecf 100644 --- a/src/core/runner.ts +++ b/src/core/runner.ts @@ -102,19 +102,17 @@ export default class Runner { } async captureScreenshot(page: Driver['page'], step: Step) { - const buffer = await page - .screenshot({ + try { + const buffer = await page.screenshot({ type: 'jpeg', quality: 80, timeout: 5000, }) - .catch(() => {}); - /** - * Write the screenshot image buffer with additional details (step - * information) which could be extracted at the end of - * each journey without impacting the step timing information - */ - if (buffer) { + /** + * Write the screenshot image buffer with additional details (step + * information) which could be extracted at the end of + * each journey without impacting the step timing information + */ const fileName = `${generateUniqueId()}.json`; const screenshot: Screenshot = { step, @@ -126,6 +124,9 @@ export default class Runner { JSON.stringify(screenshot) ); log(`Runner: captured screenshot for (${step.name})`); + } catch (_) { + // Screenshot may fail sometimes, log and continue. + log(`Runner: failed to capture screenshot for (${step.name})`); } } diff --git a/src/plugins/tracing.ts b/src/plugins/tracing.ts index e3873acc..422b2c17 100644 --- a/src/plugins/tracing.ts +++ b/src/plugins/tracing.ts @@ -38,7 +38,7 @@ export type TraceOptions = { * https://chromedevtools.github.io/devtools-protocol/tot/Tracing/ */ export class Tracing { - constructor(private driver: Driver, private options: TraceOptions) {} + constructor(private driver: Driver, private options: TraceOptions) { } async start() { log(`Plugins: started collecting trace events`); diff --git a/src/sdk/trace-processor.ts b/src/sdk/trace-processor.ts index ad8f70dc..190a0f3f 100644 --- a/src/sdk/trace-processor.ts +++ b/src/sdk/trace-processor.ts @@ -140,7 +140,7 @@ export class TraceProcessor extends LighthouseTraceProcessor { metrics: perfMetrics, }; } catch (e) { - log(e); + log(`Plugins: error processing trace events: ${e}`); return {}; } }