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

RuntimeError: Refused to compile or instantiate WebAssembly module because 'unsafe-eval' #2815

Open
paul-gansca opened this issue Jul 11, 2024 · 6 comments

Comments

@paul-gansca
Copy link

paul-gansca commented Jul 11, 2024

Describe the bug
image

I have just migrated from CRA to Vite 5.2.0 and as I was testing my app for any issues caused by this I find that I can no longer use @react-pdf/renderer (specifically ) to create a PDF because of a CSP issue. It still works if I add the unsafe-eval to the CSP string but I'm sure there has to be a better way. I'm also curious as to why it was working before.

Using ASP.NET on the BE with Dotnet 6.

To Reproduce

Running the client app on it's own doesn't throw any errors.

Running the app through the port which then has a websocket to connect to my server is when I'm getting the error.

Previously when using CRA this was not an issue.

I'm wondering if there is some extra config I need to do to handle stuff in VITE which may have been automatically done by CRA.

I'm using
"@react-pdf/renderer": "^3.2.0",
"vite": "^5.2.0",

On loading the page where I use component I get the error in the screenshot above.

Expected behavior
I'm hoping to get it working as it was with CRA without having to use 'unsafe-eval'

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • React-pdf version 3.2.0

I've seen this issue mentioned in this thread but didn't seem like it was resolved:
#510

@prasanthkumaar
Copy link

+1. am facing this issue too!

@paul-gansca
Copy link
Author

+1. am facing this issue too!

I figured it out mate, it's about enforcing a very specific set of resolutions (sub dependency package versions)

@react-pdf/renderer@3.1.2
@react-pdf/layout@3.6.2

@prasanthkumaar
Copy link

prasanthkumaar commented Aug 12, 2024

cool! thanks for figuring it out @paul-gansca 👍 setting those specific resolutions fixed it for me as well

@ashatat
Copy link

ashatat commented Aug 15, 2024

+1. am facing this issue too!

I figured it out mate, it's about enforcing a very specific set of resolutions (sub dependency package versions)

@react-pdf/renderer@3.1.2 @react-pdf/layout@3.6.2

I am still facing the issue, tried these versions and still having the issue.

anyone have any idea?

@paul-gansca
Copy link
Author

+1. am facing this issue too!

I figured it out mate, it's about enforcing a very specific set of resolutions (sub dependency package versions)
@react-pdf/renderer@3.1.2 @react-pdf/layout@3.6.2

I am still facing the issue, tried these versions and still having the issue.

anyone have any idea?

Have you checked with "npm ls" that you indeed have these versions?

I was only able to enforce the the sub-dependency version using yarn btw.

@ashatat
Copy link

ashatat commented Aug 15, 2024

@paul-gansca You were right, it wasn't getting the correct packages, I had to roll back yarn.lock to and add it in the "resolutions" and it worked
Thank you very much 🙏

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

3 participants