GoogleChrome/lighthouse · error · Error

Invalid precomputed lantern data file

Error message

Invalid precomputed lantern data file

What it means

Lantern is Lighthouse's throttling-simulation engine. The --precomputed-lantern-data flag lets you supply pre-measured network round-trip times (additionalRttByOrigin) and server response times (serverResponseTimeByOrigin) as a JSON file so the simulator skips estimation. This error fires after JSON.parse succeeds but the resulting object lacks one or both required top-level keys, meaning the file is structurally a JSON object but semantically incomplete for Lantern.

Source

Thrown at cli/bin.js:104

  } else if (cliFlags.quiet) {
    cliFlags.logLevel = 'silent';
  }
  log.setLevel(cliFlags.logLevel);

  if (
    cliFlags.output.length === 1 &&
    cliFlags.output[0] === Printer.OutputMode.json &&
    !cliFlags.outputPath
  ) {
    cliFlags.outputPath = 'stdout';
  }

  if (cliFlags.precomputedLanternDataPath) {
    const lanternDataStr = fs.readFileSync(cliFlags.precomputedLanternDataPath, 'utf8');
    /** @type {LH.PrecomputedLanternData} */
    const data = JSON.parse(lanternDataStr);
    if (!data.additionalRttByOrigin || !data.serverResponseTimeByOrigin) {
      throw new Error('Invalid precomputed lantern data file');
    }

    cliFlags.precomputedLanternData = data;
  }

  if (!Array.isArray(cliFlags.chromeFlags)) {
    cliFlags.chromeFlags = [cliFlags.chromeFlags];
  }
  cliFlags.chromeFlags.push('--enable-features=DevToolsWebMCPSupport');

  // By default, cliFlags.enableErrorReporting is undefined so the user is
  // prompted. This can be overridden with an explicit flag or by the cached
  // answer returned by askPermission().
  if (typeof cliFlags.enableErrorReporting === 'undefined') {
    cliFlags.enableErrorReporting = await askPermission();
  }
  if (cliFlags.enableErrorReporting) {
    await Sentry.init({

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Open the JSON file and confirm it has both 'additionalRttByOrigin' and 'serverResponseTimeByOrigin' keys, each containing an object like {"https://example.com": 123}
  2. Regenerate the file using Lighthouse's lantern data collection (e.g., run with --throttling-method=simulate and extract the data, or use the devtools-lantern scripts in the Lighthouse repo)
  3. Remove the --precomputed-lantern-data flag entirely to let Lantern estimate throttling values automatically

Example fix

// before (file contents):
// {"serverResponseTimeByOrigin": {"https://example.com": 250}}
// --precomputed-lantern-data=./lantern.json

// after (file contents):
// {
//   "additionalRttByOrigin": {"https://example.com": 100},
//   "serverResponseTimeByOrigin": {"https://example.com": 250}
// }
Defensive patterns

Strategy: validation

Validate before calling

// Validate lantern data file before passing to Lighthouse
const fs = require('fs');
function validateLanternData(filePath) {
  const raw = fs.readFileSync(filePath, 'utf8');
  const data = JSON.parse(raw); // throws on invalid JSON
  if (!data.additionalRttByOrigin || typeof data.additionalRttByOrigin !== 'object') {
    throw new Error('Missing or invalid additionalRttByOrigin');
  }
  if (!data.serverResponseTimeByOrigin || typeof data.serverResponseTimeByOrigin !== 'object') {
    throw new Error('Missing or invalid serverResponseTimeByOrigin');
  }
  return true;
}

Type guard

/** @param {unknown} data */
function isValidLanternData(data) {
  if (typeof data !== 'object' || data === null) return false;
  const d = /** @type {Record<string, unknown>} */ (data);
  return typeof d.additionalRttByOrigin === 'object' && d.additionalRttByOrigin !== null &&
         typeof d.serverResponseTimeByOrigin === 'object' && d.serverResponseTimeByOrigin !== null;
}

Prevention

When it happens

Trigger: Passing --precomputed-lantern-data=path/to/file.json where the file is valid JSON but is missing the 'additionalRttByOrigin' key, the 'serverResponseTimeByOrigin' key, or both. Each key must be present and truthy (an object mapping origin strings to millisecond numbers).

Common situations: Using an outdated lantern data file from an older Lighthouse version with a different schema; hand-editing the JSON and accidentally removing a key; pointing the flag at the wrong JSON file (e.g., a Lighthouse report instead of a lantern data file); partial or truncated file export.

Related errors


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