Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minified version of pdf worker doesn't send correct exception #12797

Closed
Wykks opened this issue Dec 30, 2020 · 2 comments
Closed

Minified version of pdf worker doesn't send correct exception #12797

Wykks opened this issue Dec 30, 2020 · 2 comments

Comments

@Wykks
Copy link

Wykks commented Dec 30, 2020

Configuration:

  • Web browser and its version: Chrome
  • Operating system and its version: Windows 10
  • PDF.js version: 2.5.207
  • Is a browser extension: No

Steps to reproduce the problem:

Just use any not pdf file to trigger a InvalidPdfException

getDocument().promise.catch((error) => console.log(error);
error is undefined when using the minified version of the pdf worker (the one inside pdfjs-dist/build/pdf.worker.min.js).

What is the expected behavior?

The error should be InvalidPDFException {message: "Invalid PDF structure.", name: "InvalidPDFException"} even when using the minified version of the pdf worker.

What went wrong?

Using pdf.worker.es5.js (should be fine with pdf.worker.js too):
image

Using pdf.worker.min.js:
image

And here:

pdf.js/src/display/api.js

Lines 2332 to 2350 in 6e55326

messageHandler.on("DocException", function (ex) {
let reason;
switch (ex.name) {
case "PasswordException":
reason = new PasswordException(ex.message, ex.code);
break;
case "InvalidPDFException":
reason = new InvalidPDFException(ex.message);
break;
case "MissingPDFException":
reason = new MissingPDFException(ex.message);
break;
case "UnexpectedResponseException":
reason = new UnexpectedResponseException(ex.message, ex.status);
break;
case "UnknownErrorException":
reason = new UnknownErrorException(ex.message, ex.details);
break;
}

reason is not going to be defined when name === 'e'

@Wykks Wykks changed the title Minified version of pdf worker doesn't raise correct exception Minified version of pdf worker doesn't send correct exception Dec 30, 2020
@Snuffleupagus
Copy link
Collaborator

Duplicate of #11941 and #12209.

@Wykks
Copy link
Author

Wykks commented Dec 30, 2020

Oh welp, I did a search before posting, without success.... Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants