Skip to content

[BUG] Missing OpenJPEG WASM fallback file causing image decode failures #271

@skifli

Description

@skifli

🐛 Bug Description

When processing PDFs with images, the OpenJPEG WASM module fails to initialize due to a missing fallback file (named 'nullopenjpeg_nowasm_fallback.js'), causing image decode failures across all pages.

📋 Steps to Reproduce

  1. Install pdf-reader-mcp via npx or npm
  2. Attempt to process a PDF containing images
  3. Observe the OpenJPEG errors in the logs

✅ Expected Behavior

Images within PDFs should decode correctly or gracefully fall back to non-WASM/Javascript implementation.

❌ Actual Behavior

Images fail to decode with "JpxError: OpenJPEG failed to initialize" error.

📸 Screenshots / Logs

Apr 09 14:17:59 lyra npx[120832]: Warning: Bad value, for custom key "AAPL:Keywords", in Info: .
Apr 09 14:17:59 lyra npx[120832]: Warning: UnknownErrorException: Ensure that the `standardFontDataUrl` API parameter is provided.
Apr 09 14:17:59 lyra npx[120832]: Warning: JpxImage#instantiateWasm: UnknownErrorException: Ensure that the `wasmUrl` API parameter is provided.
Apr 09 14:17:59 lyra npx[120832]: Warning: JpxImage#getJsModule: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'nullopenjpeg_nowasm_fallback.js' imported from /home/ami/.npm/_npx/673e420c0bc15d5b/node_modules/pdfjs-dist/legacy/build/pdf.worker.mjs
Apr 09 14:17:59 lyra npx[120832]: Warning: Unable to decode image "img_p1_1": "JpxError: OpenJPEG failed to initialize".
Apr 09 14:18:00 lyra npx[120832]: Warning: Unable to decode image "img_p13_1": "JpxError: OpenJPEG failed to initialize".
Apr 09 14:18:10 lyra npx[120832]: Warning: Bad value, for custom key "AAPL:Keywords", in Info: .
Apr 09 14:18:10 lyra npx[120832]: Warning: UnknownErrorException: Ensure that the `standardFontDataUrl` API parameter is provided.

🖥️ Environment

Package Information:

  • Package name: @sylphx/pdf-reader-mcp
  • Package version: 2.3.0
  • Installation method: npx

System Information:

  • OS: NixOS 25.11 (Xantusia)
  • Node.js version: v22.21.1
  • npm version: 10.9.4

Additional Context:

  • MCP Client: n/a (used as MCP server)

🔄 Reproducibility

  • Always

🔍 Additional Context

The issue appears to be with pdfjs-dist not properly resolving the OpenJPEG WASM module path. The file path 'nullopenjpeg_nowasm_fallback.js' suggests a null prefix being incorrectly prepended to the filename.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions