mozilla/pdf.js · warning · Error

Unknown IR type: ${IR[0]}

Error message

Unknown IR type: ${IR[0]}

What it means

Thrown by getShadingPattern when the first element of a shading pattern's IR (intermediate representation) is not 'RadialAxial', 'Mesh', or 'Dummy'. The display layer switches on this type tag to pick the pattern constructor; an unknown tag means the worker and display layer disagree on the IR vocabulary. It is an internal/render-path condition usually caused by version skew or an unsupported pattern.

Source

Thrown at src/display/pattern_helper.js:544

  }
}

class DummyShadingPattern extends BaseShadingPattern {
  getPattern() {
    return "hotpink";
  }
}

function getShadingPattern(IR) {
  switch (IR[0]) {
    case "RadialAxial":
      return new RadialAxialShadingPattern(IR);
    case "Mesh":
      return new MeshShadingPattern(IR);
    case "Dummy":
      return new DummyShadingPattern();
  }
  throw new Error(`Unknown IR type: ${IR[0]}`);
}

const PaintType = {
  COLORED: 1,
  UNCOLORED: 2,
};

class TilingPattern {
  // 10in @ 300dpi shall be enough.
  static MAX_PATTERN_SIZE = 3000;

  constructor(IR, ctx, canvasGraphicsFactory, baseTransform) {
    this.color = IR[1];
    this.operatorList = IR[2];
    this.matrix = IR[3];
    this.bbox = IR[4];
    this.xstep = IR[5];
    this.ystep = IR[6];

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Ensure worker and API builds come from the same PDF.js release.
  2. Update PDF.js to the latest version.
  3. Catch per-page render errors so the document stays usable.
  4. Report the PDF upstream if it reproduces on the latest release.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await page.render({ canvasContext }).promise;
} catch (e) {
  if (e.message.startsWith('Unknown IR type')) {
    // likely worker/API version skew; re-render with matching builds
  }
}

Prevention

When it happens

Trigger: getShadingPattern(IR) is called with IR[0] outside the recognized set during canvas rendering of a shaded region.

Common situations: pdf.worker and the display API are from different PDF.js versions; a PDF uses a shading type the current build cannot serialize; a corrupted pattern stream produces a bad IR tag.

Related errors


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