diff --git a/core/runner.js b/core/runner.js index 365ec3a7ffa5..819030b71236 100644 --- a/core/runner.js +++ b/core/runner.js @@ -199,32 +199,27 @@ class Runner { data: sentryContext, }); - /** @type {LH.Artifacts} */ - let artifacts; if (settings.auditMode && !settings.gatherMode) { // No browser required, just load the artifacts from disk. const path = this._getDataSavePath(settings); - artifacts = assetSaver.loadArtifacts(path); - } else { - const runnerStatus = {msg: 'Gather phase', id: 'lh:runner:gather'}; - log.time(runnerStatus, 'verbose'); - - artifacts = await gatherFn({ - resolvedConfig: options.resolvedConfig, - }); - - log.timeEnd(runnerStatus); - - // If `gather` is run multiple times before `audit`, the timing entries for each `gather` can pollute one another. - // We need to clear the timing entries at the end of gathering. - // Set artifacts.Timing again to ensure lh:runner:gather is included. - artifacts.Timing = log.takeTimeEntries(); - - // -G means save these to disk (e.g. ./latest-run). - if (settings.gatherMode) { - const path = this._getDataSavePath(settings); - await assetSaver.saveArtifacts(artifacts, path); - } + return assetSaver.loadArtifacts(path); + } + + const runnerStatus = {msg: 'Gather phase', id: 'lh:runner:gather'}; + log.time(runnerStatus, 'verbose'); + + const artifacts = await gatherFn({resolvedConfig: options.resolvedConfig}); + log.timeEnd(runnerStatus); + + // If `gather` is run multiple times before `audit`, the timing entries for each `gather` can pollute one another. + // We need to clear the timing entries at the end of gathering. + // Set artifacts.Timing again to ensure lh:runner:gather is included. + artifacts.Timing = log.takeTimeEntries(); + + // -G means save these to disk (e.g. ./latest-run). + if (settings.gatherMode) { + const path = this._getDataSavePath(settings); + await assetSaver.saveArtifacts(artifacts, path); } return artifacts;