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 with WebAssembly in @react-pdf/yoga on Node.js Server #2589

Open
gino8080 opened this issue Feb 2, 2024 · 5 comments · May be fixed by #2677
Open

RuntimeError with WebAssembly in @react-pdf/yoga on Node.js Server #2589

gino8080 opened this issue Feb 2, 2024 · 5 comments · May be fixed by #2677
Labels

Comments

@gino8080
Copy link

gino8080 commented Feb 2, 2024

Hello,

I've encountered a critical issue while using @react-pdf/renderer in a Node.js Express server environment. The server crashes with a RuntimeError related to WebAssembly memory allocation when attempting to generate PDFs. The error message is as follows:

RuntimeError: Aborted(RangeError: WebAssembly.instantiate(): Out of memory: wasm memory). Build with -sASSERTIONS for more info.
    at w (/usr/app/node_modules/yoga-layout/binaries/wasm-async-node.js:14:73)
    at /usr/app/node_modules/yoga-layout/binaries/wasm-async-node.js:62:60

This error suggests that the WebAssembly module within yoga-layout, which is a dependency of @react-pdf/renderer, is running out of memory.

To Reproduce

  1. Set up a basic Express server that uses @react-pdf/renderer to generate PDFs.
  2. Trigger the PDF generation endpoint with the necessary data.
  3. The server crashes with the above RuntimeError after a few successful PDF generations.
    Expected Behavior:

The PDF generation should complete successfully without causing a server crash or running out of WebAssembly memory.

Actual Behavior:

The server crashes with a RuntimeError indicating that WebAssembly ran out of memory.

Additional Context:

The issue seems to occur after generating multiple PDFs, suggesting a potential memory leak or insufficient memory allocation for WebAssembly in the yoga-layout module.
Reducing the complexity of the PDF layout temporarily mitigates the issue but does not solve it entirely.
I would appreciate any insights or suggestions on how to resolve this issue. If there are any known workarounds or if additional information is needed, please let me know.

Environment:

Node.js version: v16.18.1
Express version: ^4.18.2
@react-pdf/layout": "3.10.3",
@react-pdf/renderer": "3.3.4",
Operating System: docker image

Thank you for your time and assistance.

@Yoordi
Copy link

Yoordi commented Feb 2, 2024

Hey I have the same problem.

Did you try to use other version of @react-pdf/layout? I'm still searching a solution but dint find one at the moment.

@diegomura diegomura added the bug label Feb 3, 2024
@Yoordi
Copy link

Yoordi commented Feb 7, 2024

Switch back to 1.6.8 was the only thing which helps....

@randbytes
Copy link

Same here

Environment:
Node.js version: v20.7.0
@react-pdf/renderer": "3.1.10",
Operating System: docker image node:18-alpine

@moishinetzer
Copy link

I'm seeing the same issue as well.

[info] failed to asynchronously prepare wasm: RangeError: WebAssembly. instantiate() : Out of memory: wasm memory
[info] Aborted (RangeError: WebAssembly. instantiate () : Out of memory: wasm memory)
[info] RuntimeError: Aborted (RangeError: WebAssembly. instantiate () : Out of memory: wasm memory). Build with -sASSERTIONS for more info.
[info] at w (/ myapp/node_modules/yoga-layout/binaries/wasm-async-node.js:14:73)
[info] at /myapp/node_modules/yoga-layout/binaries/wasm-async-node.js:62:60

This was referenced Mar 15, 2024
@moishinetzer
Copy link

For anyone following this issue, as a temporary fix downgrade to the any of the following packages you may use:

@react-pdf/[email protected]
@react-pdf/[email protected]

And make sure to pin it in your package.json

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.

5 participants