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

Setting up fake worker failed #45

Open
tatarrenat opened this issue Dec 8, 2022 · 5 comments
Open

Setting up fake worker failed #45

tatarrenat opened this issue Dec 8, 2022 · 5 comments

Comments

@tatarrenat
Copy link

I have an issue when rendering the component on my app asynchronously:

Setting up fake worker failed: "Cannot load script at: http://localhost:3000/client/app/vendors-node_modules_svelte-pdf_index_js.7eb84ba08763e11d3530.worker.js".

image

image

Any idea what the problem is?

Thanks in advance!

@justin-prather
Copy link

also having this issue

@Gildedter
Copy link

Gildedter commented Jul 11, 2023

I have the same issue and found two workarounds, if you're depending elsewhere in your project to pdfjs-dist you can change (inside your node_modules folder):

pdfjs.GlobalWorkerOptions.workerSrc = new URL('pdfjs-dist/build/pdf.worker.js', import.meta.url);
to: pdf.worker.entry.js, OR fork the project and update the pdfjs-dist dependency to ^3.8.162 (latest version for me at the time of testing) and the error will go away.

Edit: Re-installing your dependencies and then restarting the dev server also fixes it sometimes, too random of a bug

@s00500
Copy link

s00500 commented Dec 25, 2023

just ran into the same issue, added the specified version to my package json and it would work !, thanks for the tipp

@rberger
Copy link

rberger commented Apr 24, 2024

I found I was able to modify svelte-pdf/src/lib/PdfViewer.svelte with the following to get workers to work

-  import * as pdfWorker from 'pdfjs-dist/build/pdf.worker.mjs'
+  import pdfWorker from 'pdfjs-dist/build/pdf.worker.mjs?worker&url'

As per
https://vitejs.dev/guide/features#web-workers
mozilla/pdf.js#8305
mozilla/pdf.js#17504

@lewisjr
Copy link

lewisjr commented May 27, 2024

to: pdf.worker.entry.js

got mine to work instead by changing it to pdf.worker.min.js

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

6 participants