{"record":{"id":"ce644308d06be9bf","repo":"mozilla/pdf.js","slug":"binarycmapreader-process-unknown-type-type","errorCode":null,"errorMessage":"BinaryCMapReader.process - unknown type: ${type}","messagePattern":"BinaryCMapReader\\.process - unknown type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/binary_cmap.js","lineNumber":312,"sourceCode":"            incHex(end, ucs2DataSize);\n            if (!sequence) {\n              stream.readHexNumber(start, ucs2DataSize);\n              addHex(start, end, ucs2DataSize);\n            } else {\n              start.set(end);\n            }\n            stream.readHexNumber(end, ucs2DataSize);\n            addHex(end, start, ucs2DataSize);\n            stream.readHex(charCode, dataSize);\n            cMap.mapBfRange(\n              hexToInt(start, ucs2DataSize),\n              hexToInt(end, ucs2DataSize),\n              hexToStr(charCode, dataSize)\n            );\n          }\n          break;\n        default:\n          throw new Error(`BinaryCMapReader.process - unknown type: ${type}`);\n      }\n    }\n\n    if (useCMap) {\n      return extend(useCMap);\n    }\n    return cMap;\n  }\n}\n\nexport { BinaryCMapReader };\n","sourceCodeStart":294,"sourceCodeEnd":324,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/binary_cmap.js#L294-L324","documentation":"Thrown by BinaryCMapReader.process() (binary_cmap.js:312) in the default case of the record-type switch. The record type is the top 3 bits of the header byte (b >> 5); types 0-5 are valid record kinds (codespacerange, notdefrange, cidchar, cidrange, bfchar, bfrange) and 7 is metadata. Type 6 (or any value produced by a misaligned stream) is unknown.","triggerScenarios":"A record header byte decodes to type === 6, or the stream is misaligned so a data byte is read as a header, yielding an unrecognized type. Triggered when the bcmap format is newer than the reader supports, the file is corrupt, or earlier mis-parsing shifted the read offset.","commonSituations":"A .bcmap produced by a newer/different tool than the reader understands; corrupt or partially-overwritten CMap file; wrong resource served at the cMapUrl; read offset desynced by an earlier malformed record.","solutions":["Upgrade PDF.js to a version whose BinaryCMapReader recognises the record types in your CMap files.","Replace the CMap file with one from the official matching release distribution.","Verify the bytes at cMapUrl are a genuine bcmap and not a text CMap or HTTP error body.","If only one CMap is affected, identify which CMap (check the network request for the failing font) and replace just that file."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// You cannot pre-validate record types without reimplementing the reader;\n// instead, keep your reader and CMaps in sync.\n// Confirm pdfjs-dist and the cmaps dir share one release version.\nimport { version } from 'pdfjs-dist';\nconsole.assert(typeof version === 'string', 'pdfjs version present');","typeGuard":null,"tryCatchPattern":"try {\n  await page.render({ canvasContext, viewport }).promise;\n} catch (err) {\n  if (/unknown type/i.test(err?.message)) {\n    console.warn('CMap record type unsupported by this pdfjs build; update or replace the CMap', err);\n  } else throw err;\n}","preventionTips":["Upgrade pdfjs-dist together with its CMap set so record types are recognised.","Replace suspect CMap files with originals from the official release.","Confirm the resource at cMapUrl is a genuine bcmap, not text or an error body.","Track which CMap fails (inspect network requests) and replace just that file."],"tags":["cmap","cjk-fonts","binary-cmap","corrupt-resource","version-skew"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}