[Resolved] Out of memory: wasm memory

#1
I have ubuntu server using nodejs.
The whole server basically is just one js file called `app.js`
app.js works with google storage and there's something strange happens.
When I run app.js by ssh terminal, everything work great. But when the same code is run by OpenLiteSpeed as VHost context, it can't handle google storage requests, throwing the error:

Code:
[STDERR] node:internal/deps/undici/undici:9336
      return await WebAssembly.instantiate(mod, {
                               ^

RangeError: WebAssembly.instantiate(): Out of memory: wasm memory
    at lazyllhttp (node:internal/deps/undici/undici:9336:32)
 
Last edited:
#2
I actually already found a fix for it. Adding it, in case someone else will face the same issue.
It happens, because WebAssembly creates 10Gb virtual block, but there's 2Gb limit in OpenLiteSpeed settings by default.
So we have memory error when run by OpenLiteSpeed. And no error, when run by terminal, because there's no limit in the terminal.
The 10Gb is not real, it won't actually load your RAM, but it still triggers the limit.

Luckily we can increase the limit, up to 12Gb, so it won't be triggered.
To do that, you need to open:
Server Configuration > App Server > Node.js App Default Settings
And then change memory soft and hard limits.

More info about the bug:
https://blog.stackblitz.com/posts/debugging-v8-webassembly/
https://github.com/nodejs/undici/issues/988
 
Top