{"record":{"id":"61ed07f911d94451","repo":"GoogleChrome/lighthouse","slug":"run-failed-to-get-metrics","errorCode":null,"errorMessage":"run failed to get metrics","messagePattern":"run failed to get metrics","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/lantern/collect/collect.js","lineNumber":198,"sourceCode":"\n  return {result: null, retries: maxAttempts - 1, errors};\n}\n\n/**\n * @param {LH.Result=} lhr\n */\nfunction assertLhr(lhr) {\n  if (!lhr) throw new Error('missing lhr');\n  if (lhr.runtimeError) throw new Error(`runtime error: ${lhr.runtimeError}`);\n  const metrics = common.getMetrics(lhr);\n  if (metrics?.firstContentfulPaint &&\n      metrics.interactive &&\n      // WPT won't have this, we'll just get from the trace.\n      // metrics.largestContentfulPaint &&\n      metrics.maxPotentialFID &&\n      metrics.speedIndex\n  ) return;\n  throw new Error('run failed to get metrics');\n}\n\nasync function main() {\n  // Resume state from previous invocation of script.\n  summary = common.loadSummary();\n\n  // Remove data if no longer in TEST_URLS.\n  summary.results = summary.results\n    .filter(urlSet => TEST_URLS.includes(urlSet.url));\n\n  fs.mkdirSync(common.collectFolder, {recursive: true});\n\n  // Traces are collected for one URL at a time, in series, so all traces are from a small time\n  // frame, reducing the chance of a site change affecting results.\n  for (const url of TEST_URLS) {\n    // This URL has been done on a previous script invocation. Skip it.\n    if (summary.results.find((urlResultSet) => urlResultSet.url === url)) {\n      log.log(`already collected traces for ${url}`);","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/lantern/collect/collect.js#L180-L216","documentation":"Thrown by assertLhr() in the Lantern data-collection script after a Lighthouse run completes. It validates that the returned Lighthouse Result (lhr) contains all required timing metrics: firstContentfulPaint, interactive (TTI), maxPotentialFID, and speedIndex. The script collects traces and metrics from real sites to build Lantern's accuracy baseline, so an lhr missing these core metrics is unusable.","triggerScenarios":"Called from runUnthrottledLocally() (collect.js:104) after a local `node cli <url>` run, and from runForWpt() (collect.js:130) after polling WebPageTest for results. Fires when common.getMetrics(lhr) returns undefined or an object missing one of the four required metric fields. The runtimeError check at line 189 fires first for page-level errors, so this specific throw means the page loaded but metric computation produced incomplete results.","commonSituations":"Target page is a slow SPA that never reaches Time To Interactive within the run timeout. Chrome crashed or was killed mid-run, producing a partial trace. A Lighthouse version regression broke metric computation (e.g., TTI observer). WPT returned a partial lhr with missing audits. The page redirected to an error page that loads instantly but has no meaningful content metrics.","solutions":["Re-run the collection — collect.js already retries up to 3 times via repeatUntilPassOrNull (line 169); if all 3 fail, the URL is recorded with null result and the script continues","Check the lhr.runtimeError field (captured at line 189) for page-level errors that precede this throw","Verify the target URL is reachable and loads normally in a browser with Chrome DevTools open","Ensure your Chrome and Lighthouse versions are compatible — metric computation can regress across major versions","If using WPT (TEST_URLS with WPT_KEY set), verify WPT ran Lighthouse successfully by inspecting the WPT JSON response directly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// collect.js already wraps in repeatUntilPassOrNull (3 retries).\n// In your own collection code:\nconst {result, errors} = await repeatUntilPassOrNull(\n  () => runUnthrottledLocally(url), 3\n);\nif (!result) {\n  console.error(`All retries failed for ${url}:`, errors);\n  continue;\n}","preventionTips":["Use repeatUntilPassOrNull to retry transient metric failures","Verify the target URL loads successfully in Chrome before bulk collection","Keep Chrome and Lighthouse versions in sync to avoid metric computation regressions","Monitor lhr.runtimeError before checking for missing metrics"],"tags":["lantern","metrics","lighthouse-result","data-collection"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}