Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

build: fix Vercel OOM — revert bundle-api batch 20→10, stagger heavy Vite phases, pin Node 22

nirholasad50e7d00852
diff --git a/package.json b/package.json
index 22cd0999f..e9bab4ac8 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"@esbuild-plugins/node-globals-polyfill": "^0.2.0"
},
"engines": {
- "node": "24.x"
+ "node": ">=22.x"
},
"keywords": [
"3d-viewer",
diff --git a/scripts/build-vercel.mjs b/scripts/build-vercel.mjs
index c6b8326c7..c99325e77 100644
--- a/scripts/build-vercel.mjs
+++ b/scripts/build-vercel.mjs
@@ -58,7 +58,9 @@ async function buildAvatarStudio() {
if (isCached('avatar-studio', inputs) && existsSync(resolve(ROOT, 'character-studio/build'))) {
return;
}
- await run('avatar-studio', 'npm run build --prefix character-studio');
+ await run('avatar-studio', 'npm run build --prefix character-studio', {
+ env: { NODE_OPTIONS: '--no-deprecation --max-old-space-size=4096' },
+ });
writeStamp('avatar-studio', inputs);
}
@@ -110,19 +112,27 @@ const totalStart = Date.now();
const phase = (n, label) => console.log(`\n=== build:vercel phase ${n}: ${label} (t+${((Date.now() - totalStart) / 1000).toFixed(1)}s) ===`);
try {
- phase(1, 'prebuild + lib + avatar-studio + chat + bundle-api (parallel)');
+ // Phase 1a: light tasks only — no Vite processes yet
+ phase(1, 'prebuild + bundle-api (parallel, light)');
await Promise.all([
prebuild(),
+ bundleApi(),
+ ]);
+
+ // Phase 1b: heavy Vite builds — run concurrently but isolated from Phase 1a
+ // to prevent 3+ Vite processes competing for RAM simultaneously.
+ // buildLib is quick (~30s) so we can sneak it in here too.
+ phase(2, 'lib + avatar-studio + chat (parallel, heavy Vite)');
+ await Promise.all([
buildLib(),
buildAvatarStudio(),
buildChat(),
- bundleApi(),
]);
- phase(2, 'app vite build');
+ phase(3, 'app vite build');
await buildApp();
- phase(3, 'post-build (copy-avatar-studio + publish-lib + r2-cors)');
+ phase(4, 'post-build (copy-avatar-studio + publish-lib + r2-cors)');
await postBuild();
clearInterval(heartbeat);
diff --git a/scripts/bundle-api.mjs b/scripts/bundle-api.mjs
index 0bb465014..99a42c2aa 100644
--- a/scripts/bundle-api.mjs
+++ b/scripts/bundle-api.mjs
@@ -138,7 +138,10 @@ function runEsbuild(files, timeoutMs) {
const start = Date.now();
const routeFiles = await collectRouteFiles(API_DIR);
-const BATCH_SIZE = 20;
+// BATCH_SIZE drives esbuild's native (Go) heap per invocation. On Vercel's
+// ~8 GB build container, 20 caused std::bad_alloc/SIGABRT when bundle-api ran
+// in parallel with the other Phase 1 native builds. Keep at 10.
+const BATCH_SIZE = 10;
const totalBatches = Math.ceil(routeFiles.length / BATCH_SIZE);
console.log(`[bundle-api] Bundling ${routeFiles.length} route files in ${totalBatches} batches...`);
diff --git a/tsconfig.json b/tsconfig.json
index b2a90bed3..92d9fe93f 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -30,6 +30,7 @@
"chat",
"chat-plugin",
"examples",
+ "infra",
"mcp-bridge",
"mcp-server",
"multiplayer",
diff --git a/vercel.json b/vercel.json
index 84f8ce8d1..b98f9b943 100644
--- a/vercel.json
+++ b/vercel.json
@@ -3,6 +3,7 @@
"outputDirectory": "dist",
"public": true,
"installCommand": "npm install --prefer-offline --no-audit --no-fund",
+ "nodeVersion": "22.x",
"env": {
"NODE_OPTIONS": "--no-deprecation"
},