[SOLVED] JavaScript heap out of memory during build on Appwrite sites
- 0
- Resolved
- 4
- Self Hosted
- Sites
I am running into heap out of memory when I am trying to build an Appwrite site. Usually this can be fixed by modifying the max-old-space-size configuration, but as far as I know, there is no way to do that in Appwrite sites.
Also the server usage is not a lot, it has a 16GB memory and less than 4GB memory is used by Appwrite even when building the site. Each core also has less than 10% usage.
I also checked the environment variables, and both _APP_COMPUTE_CPUS and _APP_COMPUTE_MEMORY are unrestricted.
[log] [nuxi] Nuxt 3.17.7 (with Nitro 2.12.9, Vite 6.4.1 and Vue 3.5.25)
[info] [nuxt:tailwindcss] Using default Tailwind CSS file
[info] [nuxi] Building for Nitro preset: `node-listener`
[info] Building client...
[info] vite v6.4.1 building for production...
[info] transforming...
<--- Last few GCs --->
[93:0x7f36a1c10000] 94416 ms: Mark-Compact 1010.2 (1043.2) -> 1002.6 (1043.7) MB, pooled: 0 MB, 1889.16 / 0.04 ms (average mu = 0.148, current mu = 0.137) allocation failure; scavenge might not succeed
[93:0x7f36a1c10000] 96338 ms: Mark-Compact 1009.7 (1043.7) -> 1003.4 (1044.2) MB, pooled: 0 MB, 1528.53 / 0.03 ms (average mu = 0.174, current mu = 0.205) task; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
bash: line 1: 82 Aborted (core dumped) npm run build
Update: I remembered I can just set the NODE_OPTIONS in package.json , but that didn't help either because the process was killed
Run `npm audit` for details.
> build
> NODE_OPTIONS=--max-old-space-size=2048 nuxt build
[log] [nuxi] Nuxt 3.17.7 (with Nitro 2.12.9, Vite 6.4.1 and Vue 3.5.25)
[info] [nuxt:tailwindcss] Using default Tailwind CSS file
[info] [nuxi] Building for Nitro preset: `node-listener`
[info] Building client...
[info] vite v6.4.1 building for production...
[info] transforming...
[info] ✓ 2638 modules transformed.
[info] rendering chunks...
bash: line 1: 83 Killed npm run build
Hey! <@802997747909001228> Have you resolved this?
Hello <@1329045306997866509>, sorry no I wasn't able to find any solution for this yet
I would really love some help
Ok! First of all, tell me whether you've NODE_OPTIONS in your sites env or not?
No, I do not have that in my sites env currently. Do you want me to try with that too?
Yes please do that if you can. And set it's value as something like this - NODE_OPTIONS=--max-old-space-size=<memory-size-you-want>
See if it works
Unfortunately it didn't, I still get this weird process that kills the npm run build
> build
> NODE_OPTIONS=--max-old-space-size=2048 nuxt build
[log] [nuxi] Nuxt 3.17.7 (with Nitro 2.12.9, Vite 6.4.1 and Vue 3.5.25)
[info] [nuxt:tailwindcss] Using default Tailwind CSS file
[info] [nuxi] Building for Nitro preset: `node-listener`
[info] Building client...
[info] vite v6.4.1 building for production...
[info] transforming...
[info] ✓ 2638 modules transformed.
[info] rendering chunks...
bash: line 1: 85 Killed npm run build
Can you show me your package.json? Do you've any heavy dependencies there?
Sure, Here is my package.json. I don't see any heavy dependencies. Also the npm install succeeds on the server, it's just the npm run build that fails. Here are the full build logs
[11:35:27] [open-runtimes] Environment preparation started.
[11:35:27] [open-runtimes] Environment preparation finished.
[11:35:27] [open-runtimes] Build command execution started.
> postinstall
> nuxt prepare
[info] [nuxt:tailwindcss] Using default Tailwind CSS file
[success] [nuxi] Types generated in .nuxt
added 1238 packages, and audited 1240 packages in 45s
243 packages are looking for funding
run `npm fund` for details
2 vulnerabilities (1 low, 1 high)
To address all issues, run:
npm audit fix
Run `npm audit` for details.
> build
> NODE_OPTIONS=--max-old-space-size=2048 nuxt build
[log] [nuxi] Nuxt 3.17.7 (with Nitro 2.12.9, Vite 6.4.1 and Vue 3.5.25)
[info] [nuxt:tailwindcss] Using default Tailwind CSS file
[info] [nuxi] Building for Nitro preset: `node-listener`
[info] Building client...
[info] vite v6.4.1 building for production...
[info] transforming...
[info] ✓ 2638 modules transformed.
[info] rendering chunks...
bash: line 1: 85 Killed npm run build
Try using dynamic imports for your chart libraries as you've so many. Also, remove those you're not using. That too could be the possible issue behind build failure
I tried removing unused libraries and I still get the same error. Is there no way to allow Appwrite to use more resources like RAM or CPU? It's not like I am maxing out on server usage. What is killing the npm run build?
Are you using any container? Like docker or something?
Other than Appwrite itself, there is no other docker container on the server.
Is that what you meant?
Yes
<@802997747909001228> Then as per what I know, you can try to build locally and upload a manual deployment. Maybe then it'll work?
Of course that will work but that wouldn't that pretty much defeat the point of Appwrite sites? I was using Appwrite sites so I do not have to manually write entire CD pipelines
I want to understand what's causing the build to fail on the server even though I have provided unrestricted compute and the resource consumption is nowhere near max
Ok. Then let's ask someone from team instead of making any false assumptions
<@462046107556511744> can you help us with this?
so i don't think the cpu and memory are being applied. Can you look at the network logs in your browser and look for the list sites or get site API call's response body?
something like /sites or /sites/:id
Recommended threads
- [SOLVED] Error upgrading from 1.8.1 to 1...
DO Self-hosted server failed to upgrade with this error "Error response from daemon: client version 1.52 is too new. Maximum supported API version is 1.42". U...
- MariaDB refuses to connect to appwrite
Earlier, I tried updating my Appwrite version from 18.1.x to the latest release because my Flutter package required it to function properly. I used the official...
- Static IP for security purpose!
Hey I am hosting a next.js project in appwrite it reaches out to mongo DB to fetch data The only option to enable network access to 0.0.0.0/0 in mongo DB (any ...