mozilla/pdf.js · error · Error

coverage_search failed (exit code ${result.status})

Error message

coverage_search failed (exit code ${result.status})

What it means

Same spawnSync block as 386, but this is the branch where the child process launched and ran but exited non-zero (`result.status !== 0` and `result.error` is undefined). The coverage_search.mjs script itself failed — index download failed, the `--code` argument was malformed, or the script threw internally. stderr was inherited (visible in the console), so the real cause is printed above this throw. The exit code is surfaced so the gulp task fails rather than silently running zero tests.

Source

Thrown at gulpfile.mjs:930

// For a --code=<file>::<line|function> argument, runs coverage_search to find
// the ref tests that exercise that location and returns their IDs (an empty
// array when none match locally). Returns null when --code wasn't given; throws
// when the search itself fails.
function resolveCodeTestIds() {
  const codeArg = getArgValue("--code");
  if (!codeArg) {
    return null;
  }
  // Inherit stderr so the index download progress is visible; stdout is
  // captured because it carries the matching test IDs.
  const result = spawnSync("node", getCoverageSearchArgs(codeArg), {
    encoding: "utf8",
    stdio: ["ignore", "pipe", "inherit"],
  });
  if (result.status !== 0) {
    // status is null when the child couldn't be spawned or was killed by a
    // signal; surface the real cause instead of a generic message.
    throw new Error(
      result.error
        ? `coverage_search failed: ${result.error.message}`
        : `coverage_search failed (exit code ${result.status})`
    );
  }
  let testIds = result.stdout.trim().split("\n").filter(Boolean);

  // The published index is built from master, so some covering tests may not
  // exist on this branch. Drop them (with a note) rather than letting test.mjs
  // reject the whole run — and silently exit 0 — on the first unknown ID.
  const knownIds = readManifestTestIds();
  if (knownIds) {
    const missing = testIds.filter(id => !knownIds.has(id));
    if (missing.length) {
      console.log(
        `\n### Ignoring ${missing.length} covered test(s) not in the manifest:\n` +
          missing.map(id => `  ${id}`).join("\n")
      );

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Read the stderr lines printed just before the throw — coverage_search.mjs explains why it exited.
  2. If `--no-download` is in play, supply a valid `--index=<path>` or remove `--no-download` to allow fetching.
  3. Confirm the `--code=<path>` argument is a real path that exists in the repo.
  4. If the index format is stale, regenerate or re-download it; update external/ccov tooling if needed.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: if --no-download is set, ensure a local index exists.
function preflightCoverage(argv) {
  const noDownload = argv.includes('--no-download');
  const index = getArgValue('--index');
  if (noDownload && !index) throw new Error('--no-download requires --index=<local-path>');
}

Try / catch

try {
  testIds = resolveCodeTestIds();
} catch (e) {
  if (/coverage_search failed \(exit code/.test(e.message)) {
    console.warn('coverage_search exited non-zero; check stderr above. Falling back to full suite.');
    testIds = null;
  } else throw e;
}

Prevention

When it happens

Trigger: coverage_search.mjs cannot download the published index (network) and `--no-download` was set without `--index`; the `--code=<path>` value doesn't match any tracked path; the script hits an internal parse/runtime error and exits non-zero; the index format is incompatible with this version of the script.

Common situations: CI offline with `--no-download` but no local index; running coverage selection on an outdated branch whose index schema changed; passing a code path that doesn't exist in the repo.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/74ce36e6717e3113. Report an issue: GitHub.