svelte-pdf icon indicating copy to clipboard operation
svelte-pdf copied to clipboard

Setting up fake worker failed

Open tatarrenat opened this issue 2 years ago • 5 comments

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!

tatarrenat avatar Dec 08 '22 11:12 tatarrenat

also having this issue

justin-prather avatar May 21 '23 22:05 justin-prather

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): https://github.com/vinodnimbalkar/svelte-pdf/blob/87116ace904234c14bbf715bb45ecbfa9fb9306e/src/lib/PdfViewer.svelte#L26 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

Gildedter avatar Jul 11 '23 06:07 Gildedter

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

s00500 avatar Dec 25 '23 10:12 s00500

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 https://github.com/mozilla/pdf.js/issues/8305 https://github.com/mozilla/pdf.js/pull/17504

rberger avatar Apr 24 '24 06:04 rberger

to: pdf.worker.entry.js

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

lewisjr avatar May 27 '24 20:05 lewisjr