GoogleChrome/lighthouse · error
error fetching ${url}: ${response.status} ${response.statusT
Error message
error fetching ${url}: ${response.status} ${response.statusText} What it means
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.
Source
Thrown at core/scripts/lantern/collect/collect.js:50
/**
* @param {string} filename
* @param {string} data
*/
function saveData(filename, data) {
fs.mkdirSync(common.collectFolder, {recursive: true});
fs.writeFileSync(`${common.collectFolder}/${filename}`, data);
return filename;
}
/**
* @param {string} url
* @return {Promise<string>}
*/
async function fetchString(url) {
const response = await fetch(url);
if (response.ok) return response.text();
throw new Error(`error fetching ${url}: ${response.status} ${response.statusText}`);
}
/**
* @param {string} url
*/
async function startWptTest(url) {
if (!WPT_KEY) throw new Error('missing WPT_KEY');
const apiUrl = new URL('/runtest.php', WPT_URL);
apiUrl.search = new URLSearchParams({
k: WPT_KEY,
f: 'json',
url,
location: 'gce-us-east4-linux:Chrome.3GFast',
runs: '1',
lighthouse: '1',
mobile: '1',
// Make the trace file available over /getgzip.php.View on GitHub (pinned to 9515cd4e58)
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.
Defensive patterns
Strategy: retry
Validate before calling
async function fetchStringWithRetry(url, retries = 3) {
for (let i = 0; i < retries; i++) {
const res = await fetch(url);
if (res.ok) return res.text();
if (res.status < 500 && res.status !== 429) throw new Error(`error fetching ${url}: ${res.status} ${res.statusText}`);
await new Promise(r => setTimeout(r, 2000 * (i + 1)));
}
throw new Error(`error fetching ${url} after ${retries} retries`);
} Try / catch
try {
const data = await fetchString(url);
} catch (e) {
if (/error fetching/.test(e.message)) { /* log and retry or skip */ }
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: WPT test not finished when trace URL is fetched; WPT service outage; incorrect URL construction; expired test results.
Related errors
- missing WPT_KEY
- unexpected status code ${wptResponse.statusCode} ${wptRespon
- unexpected response: ${response.statusCode} ${response.statu
- runtime error: ${lhr.runtimeError}
- Invalid precomputed lantern data file
AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13).
Data as JSON: /api/errors/bfd18adb17477d12.
Report an issue: GitHub.