{"record":{"id":"166ce84ecd673b09","repo":"mozilla/pdf.js","slug":"unknown-ir-type-ir-0","errorCode":null,"errorMessage":"Unknown IR type: ${IR[0]}","messagePattern":"Unknown IR type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/display/pattern_helper.js","lineNumber":544,"sourceCode":"  }\n}\n\nclass DummyShadingPattern extends BaseShadingPattern {\n  getPattern() {\n    return \"hotpink\";\n  }\n}\n\nfunction getShadingPattern(IR) {\n  switch (IR[0]) {\n    case \"RadialAxial\":\n      return new RadialAxialShadingPattern(IR);\n    case \"Mesh\":\n      return new MeshShadingPattern(IR);\n    case \"Dummy\":\n      return new DummyShadingPattern();\n  }\n  throw new Error(`Unknown IR type: ${IR[0]}`);\n}\n\nconst PaintType = {\n  COLORED: 1,\n  UNCOLORED: 2,\n};\n\nclass TilingPattern {\n  // 10in @ 300dpi shall be enough.\n  static MAX_PATTERN_SIZE = 3000;\n\n  constructor(IR, ctx, canvasGraphicsFactory, baseTransform) {\n    this.color = IR[1];\n    this.operatorList = IR[2];\n    this.matrix = IR[3];\n    this.bbox = IR[4];\n    this.xstep = IR[5];\n    this.ystep = IR[6];","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/display/pattern_helper.js#L526-L562","documentation":"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.","triggerScenarios":"getShadingPattern(IR) is called with IR[0] outside the recognized set during canvas rendering of a shaded region.","commonSituations":"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.","solutions":["Ensure worker and API builds come from the same PDF.js release.","Update PDF.js to the latest version.","Catch per-page render errors so the document stays usable.","Report the PDF upstream if it reproduces on the latest release."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext }).promise;\n} catch (e) {\n  if (e.message.startsWith('Unknown IR type')) {\n    // likely worker/API version skew; re-render with matching builds\n  }\n}","preventionTips":["Ship worker and API bundles from the same PDF.js release.","Update PDF.js to pick up new IR types.","Catch render errors per page for resilience.","Reproduce and report PDFs that trigger unknown IR tags."],"tags":["rendering","shading-pattern","ir","version-skew"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}