mozilla/pdf.js · error · Error

app.plugins is read-only

Error message

app.plugins is read-only

What it means

app.plugins returns an empty array because PDF.js has no plugin objects. The list is viewer-managed and read-only; the setter throws. Assignment is rejected unconditionally.

Source

Thrown at src/scripting_api/app.js:306

  set openInPlace(val) {
    this._openInPlace = val;
    /* TODO */
  }

  get platform() {
    return this._platform;
  }

  set platform(_) {
    throw new Error("app.platform is read-only");
  }

  get plugins() {
    return [];
  }

  set plugins(_) {
    throw new Error("app.plugins is read-only");
  }

  get printColorProfiles() {
    return [];
  }

  set printColorProfiles(_) {
    throw new Error("app.printColorProfiles is read-only");
  }

  get printerNames() {
    return [];
  }

  set printerNames(_) {
    throw new Error("app.printerNames is read-only");
  }

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Read app.plugins only; expect [] in PDF.js.
  2. Detect plugin support via app.numPlugins (also 0).
  3. Keep any plugin-like extensibility outside the scripting API.

Example fix

// before
app.plugins = [myPlugin];
// after
const plugins = app.plugins; // [] in pdf.js
Defensive patterns

Strategy: validation

Validate before calling

// app.plugins always returns [] in pdf.js.
const pluginNames = (app) => app.plugins.map(p => p?.name);

Type guard

const isPluginList = (v) => Array.isArray(v);

Try / catch

try { /* code that may assign app.plugins */ }
catch (e) { if (!/plugins is read-only/.test(e.message)) throw e; }

Prevention

When it happens

Trigger: Any assignment app.plugins = [...] in PDF JavaScript or API test code hits the throw at src/scripting_api/app.js:306.

Common situations: Scripts trying to register plugin descriptors; authors assuming the array is a public registry.

Related errors


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