GoogleChrome/lighthouse · error

unexpected status code ${wptResponse.statusCode} ${wptRespon

Error message

unexpected status code ${wptResponse.statusCode} ${wptResponse.statusText}

What it means

Thrown by startWptTest() after parsing the WPT API JSON response when `statusCode` is not 200. WPT wraps its own status inside the JSON body (separate from HTTP status), so this fires when WPT itself rejects the test request — e.g. invalid key, quota exceeded, or bad parameters.

Source

Thrown at core/scripts/lantern/collect/collect.js:77

  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.
    lighthouseTrace: '1',
    lighthouseScreenshots: '1',
    // Disable some things that WPT does, such as a "repeat view" analysis.
    type: 'lighthouse',
  }).toString();
  const wptResponseJson = await fetchString(apiUrl.href);
  const wptResponse = JSON.parse(wptResponseJson);
  if (wptResponse.statusCode !== 200) {
    throw new Error(`unexpected status code ${wptResponse.statusCode} ${wptResponse.statusText}`);
  }

  return {
    testId: wptResponse.data.testId,
    jsonUrl: wptResponse.data.jsonUrl,
  };
}

/**
 * @param {string} url
 * @return {Promise<Result>}
 */
async function runUnthrottledLocally(url) {
  const artifactsFolder = `${LH_ROOT}/.tmp/collect-traces-artifacts`;
  const {stdout} = await execFileAsync('node', [
    `${LH_ROOT}/cli`,
    url,
    '--throttling-method=provided',

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Check the wptResponse.statusText and statusCode in the error for WPT's specific rejection reason.
  2. Verify WPT_KEY is valid and has remaining quota at webpagetest.org.
  3. Confirm the location string (`gce-us-east4-linux:Chrome.3GFast`) and other params are still supported by the current WPT API.
Defensive patterns

Strategy: try-catch

Validate before calling

function assertWptStatus(wptResponse) {
  if (wptResponse.statusCode !== 200) {
    throw new Error(`WPT rejected test: ${wptResponse.statusCode} ${wptResponse.statusText}`);
  }
}

Try / catch

try {
  return await startWptTest(url);
} catch (e) {
  if (/unexpected status code/.test(e.message)) {
    console.error(`WPT test start failed: ${e.message}. Check WPT_KEY and quota.`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the WPT `/runtest.php` endpoint with an invalid/expired WPT_KEY, exceeded test quota, unsupported location, or malformed test parameters.

Common situations: Expired WPT key; daily/monthly test quota exhausted; WPT location string changed; parameter format changed in a WPT API update.

Related errors


AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13). Data as JSON: /api/errors/51944abac7e7d257. Report an issue: GitHub.