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.

fix(vercel): lazy-load chromium/puppeteer to break 45-min NFT trace explosion

nirholas4d221417669e
diff --git a/.vercelignore b/.vercelignore
index 7e88c5213..63a26c62d 100644
--- a/.vercelignore
+++ b/.vercelignore
@@ -25,6 +25,11 @@ agent-voice-chat
agent-protocol-sdk
vendor
+infra
+crates
+experiments
+scratch
+
dist-lib
dist-artifact
diff --git a/api/_lib/render-clip.js b/api/_lib/render-clip.js
index 9fc0ba570..ce42990a6 100644
--- a/api/_lib/render-clip.js
+++ b/api/_lib/render-clip.js
@@ -14,8 +14,9 @@
// MCP tool, the OG card, and any future video renderer share lighting +
// framing.
-import puppeteer from 'puppeteer-core';
-import chromium from '@sparticuz/chromium-min';
+// puppeteer-core + @sparticuz/chromium-min are loaded lazily inside getBrowser()
+// so Vercel's NFT doesn't statically trace the chromium tree for every route
+// that transitively imports this module — that trace caused 45-min build hangs.
import { env } from './env.js';
import { PRESETS } from '../../src/pose-presets.js';
@@ -28,6 +29,10 @@ let _browserPromise = null;
async function getBrowser() {
if (_browserPromise) return _browserPromise;
_browserPromise = (async () => {
+ const [{ default: puppeteer }, { default: chromium }] = await Promise.all([
+ import('puppeteer-core'),
+ import('@sparticuz/chromium-min'),
+ ]);
const executablePath = await chromium.executablePath(CHROMIUM_PACK);
return puppeteer.launch({
args: chromium.args,
diff --git a/api/_lib/render-glb.js b/api/_lib/render-glb.js
index 5ad311b04..ec9c543a1 100644
--- a/api/_lib/render-glb.js
+++ b/api/_lib/render-glb.js
@@ -9,8 +9,9 @@
// avatar row's thumbnail_key is updated — subsequent crawls hit the
// redirect path and never re-launch chromium.
-import puppeteer from 'puppeteer-core';
-import chromium from '@sparticuz/chromium-min';
+// puppeteer-core + @sparticuz/chromium-min are loaded lazily inside getBrowser()
+// so Vercel's NFT doesn't statically trace the chromium tree for every route
+// that transitively imports this module — that trace caused 45-min build hangs.
import { env } from './env.js';
// The "-min" build of @sparticuz/chromium ships without the chromium binary
@@ -36,6 +37,10 @@ let _browserPromise = null;
async function getBrowser() {
if (_browserPromise) return _browserPromise;
_browserPromise = (async () => {
+ const [{ default: puppeteer }, { default: chromium }] = await Promise.all([
+ import('puppeteer-core'),
+ import('@sparticuz/chromium-min'),
+ ]);
const executablePath = await chromium.executablePath(CHROMIUM_PACK);
return puppeteer.launch({
args: chromium.args,
diff --git a/api/avatar/render.js b/api/avatar/render.js
index 6e136b34b..f637bf1d5 100644
--- a/api/avatar/render.js
+++ b/api/avatar/render.js
@@ -22,8 +22,9 @@
// to the avatar (appearance, GLB, etc.) automatically bust the cache.
import { createHash } from 'node:crypto';
-import puppeteer from 'puppeteer-core';
-import chromium from '@sparticuz/chromium-min';
+// puppeteer-core + @sparticuz/chromium-min are loaded lazily inside getBrowser()
+// so Vercel's NFT does not statically trace the chromium binary tree on every
+// route in this function package — that trace was the 45-min build timeout.
import { cors, error, json, wrap } from '../_lib/http.js';
import { env } from '../_lib/env.js';
import { getAvatar } from '../_lib/avatars.js';
@@ -247,6 +248,10 @@ let _browserPromise = null;
async function getBrowser() {
if (_browserPromise) return _browserPromise;
_browserPromise = (async () => {
+ const [{ default: puppeteer }, { default: chromium }] = await Promise.all([
+ import('puppeteer-core'),
+ import('@sparticuz/chromium-min'),
+ ]);
const executablePath = await chromium.executablePath(CHROMIUM_PACK);
return puppeteer.launch({
args: chromium.args,
diff --git a/public/features.json b/public/features.json
index 612e9e30e..bd919c6e4 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-05-29T01:24:41.241Z",
+ "generated_at": "2026-05-29T03:10:09.329Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/scripts/bundle-api.mjs b/scripts/bundle-api.mjs
index 99a42c2aa..0de9e303b 100644
--- a/scripts/bundle-api.mjs
+++ b/scripts/bundle-api.mjs
@@ -81,6 +81,7 @@ const EXTERNALS = [
'@csstools/*',
'@neynar/*',
'@upstash/*',
+ '@sparticuz/*',
'jsdom',
'ethers',
'elevenlabs',