Skip to content

[Bug]: Invalid new URL usage in build/pdf.worker.mjs #19921

@nicolo-ribaudo

Description

@nicolo-ribaudo

Attach (recommended) or Link to PDF file

n/a

Web browser and its version

n/a

Operating system and its version

n/a

PDF.js version

5.2.133

Is the bug present in the latest PDF.js version?

Yes

Is a browser extension

No

Steps to reproduce the problem

The pdfjs-dist/build/pdf.worker.mjs file contains this code:

  if (typeof module_or_path === 'undefined') {
    module_or_path = new URL(
    /*webpackIgnore: true*/
    /*@vite-ignore*/
    'qcms_bg.wasm', import.meta.url);
  }

Which resolves to <something>/pdfjs-dist/build/qcms_bg.wasm. However, the correct URL is <something>/pdfjs-dist/wasm/qcms_bg.wasm.

What is the expected behavior?

That code is just a fallback for when the path is not explicitly specified by the user. However, it's a fallback that will never work, because it resolves to a file that is guaranteed to not exist.

Either the fallback should be fixed to resolve to the correct file (better), or it should just be removed making the use-provided path required.

Probably fixing the fallback to use the right path would also allow getting rid of the webpack/vite comments.

What went wrong?

/

Link to a viewer

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions