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

create-react-app example uses a fake worker #11729

Closed
artdent opened this issue Mar 23, 2020 · 2 comments · Fixed by #11864
Closed

create-react-app example uses a fake worker #11729

artdent opened this issue Mar 23, 2020 · 2 comments · Fixed by #11864
Labels

Comments

@artdent
Copy link

artdent commented Mar 23, 2020

Configuration:

  • PDF.js version: 2.4.456

Steps to reproduce the problem:

  1. cd examples/create-react-app
  2. npm install && npm start
  3. Open the js console
  4. Observe Warning: Setting up fake worker.

What is the expected behavior?
Example loads pdfjs.worker as an actual web worker

What went wrong?
A fake worker was used

Currently, examples/create-react-app/package.json depends on pdfjs-dist version 2.2.228, but I upgraded it to 2.4.456 and observed the same behavior.

A workaround is to serve the js worker statically in the public/, but it would be nice if the example included in the pdf.js repository were working out of the box.

@Snuffleupagus
Copy link
Collaborator

Observe Warning: Setting up fake worker.

Looking at

import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry';
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
and then https://github.com/mozilla/pdfjs-dist/blob/a3a0d672c2f3464e4bff95ad0a3b41341eb65a26/build/pdf.worker.entry.js, the example looks trivially wrong since that's obviously not how workerSrc can/should be used (given that it should be assigned a string).

Currently, examples/create-react-app/package.json depends on pdfjs-dist version 2.2.228,

Having the version number hard-coded really isn't good :-(


The general problem with the create-react-app example is that none of the few regular PDF.js contributors know much (or even anything) about React.
Consequently it's very difficult for us to maintain that example, not to mention provide support for it, and I do wonder if having it ends up does more harm than good!? @timvandermeij Should we perhaps consider removing that example?

@timvandermeij
Copy link
Contributor

/cc @luistak Would you perhaps be willing to update the example given the feedback in this issue?

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

Successfully merging a pull request may close this issue.

3 participants