{"record":{"id":"bfd18adb17477d12","repo":"GoogleChrome/lighthouse","slug":"error-fetching-url-response-status-respon","errorCode":null,"errorMessage":"error fetching ${url}: ${response.status} ${response.statusText}","messagePattern":"error fetching (.+?): (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/lantern/collect/collect.js","lineNumber":50,"sourceCode":"\n/**\n * @param {string} filename\n * @param {string} data\n */\nfunction saveData(filename, data) {\n  fs.mkdirSync(common.collectFolder, {recursive: true});\n  fs.writeFileSync(`${common.collectFolder}/${filename}`, data);\n  return filename;\n}\n\n/**\n * @param {string} url\n * @return {Promise<string>}\n */\nasync function fetchString(url) {\n  const response = await fetch(url);\n  if (response.ok) return response.text();\n  throw new Error(`error fetching ${url}: ${response.status} ${response.statusText}`);\n}\n\n/**\n * @param {string} url\n */\nasync function startWptTest(url) {\n  if (!WPT_KEY) throw new Error('missing WPT_KEY');\n\n  const apiUrl = new URL('/runtest.php', WPT_URL);\n  apiUrl.search = new URLSearchParams({\n    k: WPT_KEY,\n    f: 'json',\n    url,\n    location: 'gce-us-east4-linux:Chrome.3GFast',\n    runs: '1',\n    lighthouse: '1',\n    mobile: '1',\n    // Make the trace file available over /getgzip.php.","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/lantern/collect/collect.js#L32-L68","documentation":"Thrown by fetchString() in the Lantern collection script when a fetch() to a URL completes but returns a non-ok HTTP status. This is the generic HTTP-fetch guard used by the WPT integration to download pages, API JSON, and trace files.","triggerScenarios":"Fetching a URL (WPT test JSON, trace file, or page HTML) that returns 4xx/5xx — e.g. 404 for a not-yet-available trace, 500 from WPT, or network proxy errors.","commonSituations":"WPT test not finished when trace URL is fetched; WPT service outage; incorrect URL construction; expired test results.","solutions":["Check the URL printed before the fetch and verify it is reachable in a browser/curl.","If fetching a trace too early, ensure the polling loop (pollTestUntilComplete) has confirmed test completion first.","Retry transient WPT errors after a short delay."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function fetchStringWithRetry(url, retries = 3) {\n  for (let i = 0; i < retries; i++) {\n    const res = await fetch(url);\n    if (res.ok) return res.text();\n    if (res.status < 500 && res.status !== 429) throw new Error(`error fetching ${url}: ${res.status} ${res.statusText}`);\n    await new Promise(r => setTimeout(r, 2000 * (i + 1)));\n  }\n  throw new Error(`error fetching ${url} after ${retries} retries`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const data = await fetchString(url);\n} catch (e) {\n  if (/error fetching/.test(e.message)) { /* log and retry or skip */ }\n  throw e;\n}","preventionTips":["Verify URLs are well-formed and reachable before bulk fetching.","Only fetch trace URLs after confirming the WPT test is complete.","Retry transient 5xx/429 errors with backoff."],"tags":["network","wpt","fetch","lantern","http"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}