worker issue with Gatsby 4 / webpack 5
See original GitHub issueBefore you start - checklist
- I followed instructions in documentation written for my React-PDF version
- I have checked if this bug is not already reported
- I have checked if an issue is not listed in Known issues
- If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo
Description
I’m using Gatsby 4 (with webpack 5) and it works fine in develop mode. However in production mode (gatsby build; gatsby serve
) I get the following error in the console:
GET http://localhost:9001/[object%20Object] 404 (Not Found)
The PDF fails to render and instead I get an error message Failed to load PDF file.
Steps to reproduce
- clone https://github.com/jakoblind/gatsby-react-pdf-bug-repro
- npm install
- npx gatsby build
- npx gatsby serve
- go to http://localhost:9000/
- Se error as described above.
Expected behavior
To se a rendered PDF
Actual behavior
The PDF fails to render and instead I get an error message Failed to load PDF file.
Additional information
No response
Environment
- React-PDF version: 5.7.2
- React version: 17.0.1
- Webpack version (if applicable): 5
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Webpack v5 polyfill error with Gatsby site - Stack Overflow
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. This is no longer the case.
Read more >Troubleshooting Common Errors - Gatsby
If you encounter a webpack error that says Generating SSR bundle failed after installing a plugin and trying to run gatsby develop or...
Read more >To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >Barebones Web Workers - Bayan Bennett
Barebones Web Workers. Gatsby JS. Webpack. JavaScript. Once there is enough of a reason to offload calculations into another thread, WebWorkers begin to ......
Read more >Use Web Workers in a Gatsby project - DEV Community
Tagged with gatsby, javascript, webpack. ... approach in a GitHub issue, and decided to write it up here for anyone ... doExpensiveTask(5) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@egemenu Try this
Does that work for you without
CopyWebpackPlugin
? it does for me.Hi @jakoblind,
I solved the same issue by loading the worker this way:
I found these instructions here even though it is not related to webpack: https://github.com/wojtekmaj/react-pdf#standard-browserify-esbuild-and-others
It worked with
gatsby serve
and on Netlify.Hope it solves your issue.