You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building large projects on vercel/netlify sveltekit builds fails due to exceeding build memory allocations.
I believe this issue is related to vite/esbuild - kit maintainers if you feel I should post the issue elsewhere please let me know but I thought it would be best to make the issue known here first.
Context
We have migrated our codebase to sveltekit a long time ago and have been loving it. In the last few months I created a branch to upgrade our core svelte packages to the latest versions. Everything worked locally but I kept running into vague esbuild errors with every deploy to Vercel. After experimenting with many different sveltekit, esbuild and vite configs I could not get our project to build successfully on Vercel. I deployed the same code to Netlify and got a memory heap allocation error which narrowed down the cause of the issue.
Problem
I believe the issue is that during the building/bundling esbuild is transforming too many files in parallel and holding too much in memory which results in a javascript heap allocation error.
This error is easily reproducible and I have provided an example repo below which is a fork of sveltejs/realworld. I have simply cloned the src/routes/article folder 2000 times to inflate the build. This causes a build heap error on my local machine and in Vercel. If you lower the number of cloned folders 1000 builds it will build successfully on Vercel.
In our production codebase we are at a point where this error occurs only on Vercel and is blocking us from upgrading. Obviously it is not an option for us to remove routes / components from our project so if we wish to upgrade sveltekit we are forced to consider other bespoke deployment options.
Solution
Not sure if its possible to implement some kind of progressive build strategy to combat these large builds or perhaps this issue is originating from some internal bug within esbuild package.
run npm run build locally and deploy to vercl/netlify using default configs
remove 1000 folders and commit to trigger another deploy, it should build successfully on those platforms I have done this in this PR - Axeldeblen/realworld-big-build#1
Logs
local build failure
<--- Last few GCs --->
[60557:0x104905000] 199087 ms: Scavenge (reduce) 4058.9 (4101.9) -> 4058.4 (4101.9) MB, 5.8 / 0.0 ms (average mu = 0.167, current mu = 0.052) allocation failure
[60557:0x104905000] 199106 ms: Scavenge (reduce) 4060.0 (4099.6) -> 4059.4 (4100.6) MB, 5.1 / 0.0 ms (average mu = 0.167, current mu = 0.052) allocation failure
[60557:0x104905000] 199127 ms: Scavenge (reduce) 4061.0 (4100.6) -> 4060.5 (4101.6) MB, 7.3 / 0.0 ms (average mu = 0.167, current mu = 0.052) allocation failure
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
vercel build failure
vite v2.9.6 building SSR bundle for production...
> The service was stopped
at /vercel/path0/node_modules/esbuild/lib/main.js:1335:25
at /vercel/path0/node_modules/esbuild/lib/main.js:666:9
at Socket.afterClose (/vercel/path0/node_modules/esbuild/lib/main.js:644:7)
at Socket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1334:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Error: Command "npm run build" exited with 1
According to the logs, it's failing on the SSR build phase so it's likely a Vite issue, or specifically vitejs/vite#2433. It's great that you have a repro up (though sveltekit specific), as no one really provided one in that issue. I'll close this in favor of the issue, thanks for the report!
Describe the bug
When building large projects on vercel/netlify sveltekit builds fails due to exceeding build memory allocations.
I believe this issue is related to vite/esbuild - kit maintainers if you feel I should post the issue elsewhere please let me know but I thought it would be best to make the issue known here first.
Context
We have migrated our codebase to
sveltekit
a long time ago and have been loving it. In the last few months I created a branch to upgrade our core svelte packages to the latest versions. Everything worked locally but I kept running into vagueesbuild
errors with every deploy to Vercel. After experimenting with many differentsveltekit
,esbuild
andvite
configs I could not get our project to build successfully on Vercel. I deployed the same code to Netlify and got a memory heap allocation error which narrowed down the cause of the issue.Problem
I believe the issue is that during the building/bundling
esbuild
is transforming too many files in parallel and holding too much in memory which results in a javascript heap allocation error.This error is easily reproducible and I have provided an example repo below which is a fork of
sveltejs/realworld
. I have simply cloned thesrc/routes/article
folder 2000 times to inflate the build. This causes a build heap error on my local machine and in Vercel. If you lower the number of cloned folders 1000 builds it will build successfully on Vercel.In our production codebase we are at a point where this error occurs only on Vercel and is blocking us from upgrading. Obviously it is not an option for us to remove routes / components from our project so if we wish to upgrade
sveltekit
we are forced to consider other bespoke deployment options.For reference I know Vercel provides 8GB of memory per build.
Solution
Not sure if its possible to implement some kind of progressive build strategy to combat these large builds or perhaps this issue is originating from some internal bug within
esbuild
package.Reproduction
https://github.com/Axeldeblen/realworld-big-build
run
npm run build
locally and deploy to vercl/netlify using default configsremove 1000 folders and commit to trigger another deploy, it should build successfully on those platforms I have done this in this PR - Axeldeblen/realworld-big-build#1
Logs
vercel build failure
netlify
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: