mozilla/pdf.js · error · Error

No default preferences found in "${dir}".

Error message

No default preferences found in "${dir}".

What it means

getDefaultPreferences(dir) first runs webpack over `web/app_options.js` to emit `app_options.mjs`, requires it, and calls `AppOptions.getAll(OptionKind.PREFERENCE, defaultOnly=true)`. If that returns an empty object, no preference-kind options were found, which means the webpack bundling of app_options.js silently produced an empty/broken module or app_options.js itself has no PREFERENCE entries. The guard prevents shipping a build with an empty preferences blob, which would break the viewer's defaults.

Source

Thrown at gulpfile.mjs:1224

}

function getDefaultPreferences(dir) {
  console.log(`\n### Parsing default preferences (${dir})`);

  const require = process
    .getBuiltinModule("module")
    .createRequire(import.meta.url);

  const { AppOptions, OptionKind } = require(
    "./" + DEFAULT_PREFERENCES_DIR + dir + "app_options.mjs"
  );

  const prefs = AppOptions.getAll(
    OptionKind.PREFERENCE,
    /* defaultOnly = */ true
  );
  if (Object.keys(prefs).length === 0) {
    throw new Error(`No default preferences found in "${dir}".`);
  }
  return prefs;
}

function getDefaultFtl() {
  const content = fs.readFileSync("l10n/en-US/viewer.ftl").toString(),
    stringBuf = [];

  // Strip out comments and line-breaks.
  const regExp = /^\s*#/;
  for (const line of content.split("\n")) {
    if (!line || regExp.test(line)) {
      continue;
    }
    stringBuf.push(line);
  }
  return stringBuf.join("\n");
}

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Inspect `build/<build>/default_preferences/<dir>/app_options.mjs` — confirm it actually contains the option definitions and isn't empty.
  2. Re-run the bundling step that produces app_options.mjs (defaultPreferencesConfig) and check for webpack errors in its output.
  3. Verify web/app_options.js still defines options with `OptionKind.PREFERENCE`; if you removed them all, re-add at least one or reconsider the change.
  4. Ensure the `dir` argument matches a real output directory produced by the webpack pipe.
Defensive patterns

Strategy: try-catch

Validate before calling

import { readFileSync, existsSync } from 'fs';
function preflightPreferences(dir) {
  const p = `${DEFAULT_PREFERENCES_DIR}${dir}app_options.mjs`;
  if (!existsSync(p)) throw new Error(`app_options.mjs missing at ${p}; run the bundle step`);
  const src = readFileSync(p, 'utf8');
  if (!/PREFERENCE/.test(src)) throw new Error(`${p} has no PREFERENCE-kind options`);
}

Try / catch

try {
  prefs = getDefaultPreferences(dir);
} catch (e) {
  if (/No default preferences found/.test(e.message)) {
    // rerun the webpack bundle that emits app_options.mjs, then retry once
    await bundleDefaultPreferences(dir);
    prefs = getDefaultPreferences(dir);
  } else throw e;
}

Prevention

When it happens

Trigger: The webpack2Stream step failed without throwing but emitted an empty module; app_options.js was edited to remove all PREFERENCE-kind options; the `dir` argument points at a stale/incorrect output path so the require resolves a wrong/empty module; an import in app_options.js failed to resolve under the bundler and AppOptions ended up undefined (would usually throw earlier, but a default-export shape mismatch can yield an empty getAll).

Common situations: Editing web/app_options.js while restructuring options; a broken webpack config after a dependency upgrade; running a build task that depends on default preferences before the bundle step has produced them.

Related errors


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