{"record":{"id":"f9f642d3bf914838","repo":"mozilla/pdf.js","slug":"unknown-error-f9f642","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"JpxError","httpStatus":null,"severity":"error","filePath":"src/core/jpx.js","lineNumber":70,"sourceCode":"    try {\n      const size = bytes.length;\n      ptr = module._malloc(size);\n      module.writeArrayToMemory(bytes, ptr);\n      const ret = module._jp2_decode(\n        ptr,\n        size,\n        numComponents > 0 ? numComponents : 0,\n        !!isIndexedColormap,\n        !!smaskInData,\n        reducePower\n      );\n      if (ret) {\n        const { errorMessages } = module;\n        if (errorMessages) {\n          delete module.errorMessages;\n          throw new JpxError(errorMessages);\n        }\n        throw new JpxError(\"Unknown error\");\n      }\n      const { imageData } = module;\n      module.imageData = null;\n\n      return imageData;\n    } finally {\n      if (ptr) {\n        module._free(ptr);\n      }\n    }\n  }\n\n  static parseImageProperties(stream) {\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"IMAGE_DECODERS\")) {\n      if (stream instanceof ArrayBuffer || ArrayBuffer.isView(stream)) {\n        stream = new Stream(stream);\n      } else {\n        throw new JpxError(\"Invalid data format, must be a TypedArray.\");","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/src/core/jpx.js#L52-L88","documentation":"Thrown by JpxImage.decode() when _jp2_decode returns nonzero but module.errorMessages is unset/empty. It is the generic fallback when OpenJPEG failed without producing a specific diagnostic. Distinguish it from error 172 (which carries a message).","triggerScenarios":"decode() calls _jp2_decode which returns a nonzero error code but the WASM glue didn't populate module.errorMessages. Indicates a low-level/abortive failure: null input pointer, zero size, out-of-memory, or an internal OpenJPEG abort.","commonSituations":"Empty/null bytes passed to decode, bytes.length of 0, a WASM out-of-memory on very large images, or a build/version mismatch between the WASM glue and openjpeg.wasm. Hardest JPX error to diagnose because there's no message.","solutions":["Log bytes.length and confirm bytes is a non-empty Uint8Array before calling decode.","Ensure the openjpeg.wasm version matches the JS glue shipped in your PDF.js build (don't mix versions).","Test with opj_decompress externally; if it succeeds, suspect a WASM init/memory issue.","Catch JpxError and render a placeholder so the page still loads."],"exampleFix":"// before\nconst imageData = await JpxImage.instance.decode(bytes);\n\n// after\nif (!bytes || bytes.length === 0) throw new Error('empty JPX data');\nlet imageData;\ntry {\n  imageData = await JpxImage.instance.decode(bytes);\n} catch (e) {\n  if (e.name === 'JpxError') { imageData = null; }\n  throw e;\n}","handlingStrategy":"validation","validationCode":"function isValidJpxInput(bytes) {\n  return bytes instanceof Uint8Array && bytes.length > 0;\n}\n// guard before decode:\nif (!isValidJpxInput(bytes)) throw new Error('empty/invalid JPX input');","typeGuard":"function isNonEmptyBytes(bytes) {\n  return (bytes instanceof Uint8Array) && bytes.length > 0;\n}","tryCatchPattern":"try { imageData = await JpxImage.instance.decode(bytes); }\ncatch (e) { if (e.name === 'JpxError' && /Unknown error/.test(e.message)) { imageData = null; } else throw e; }","preventionTips":["Verify bytes is a non-empty Uint8Array before calling decode.","Use matching openjpeg.wasm + JS glue versions from the same PDF.js build.","Test suspect images with opj_decompress externally to isolate WASM vs data issues."],"tags":["jpeg2000","image-decoding","wasm","jpx"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}