Skip to content

Commit 50dfa4f

Browse files
os-zhuangclaude
andauthored
fix(docs): bound docs build memory to stop Vercel OOM (exit 137) (#3221)
The @objectstack/docs build was killed on Vercel with exit 137 (SIGKILL / container OOM). The site statically prerenders 400+ MDX pages, and two things let the build's resident set exceed the 8 GB build container: 1. Next spawns one static-generation worker per CPU. On Vercel's high-core build container that fan-out multiplied peak RSS. Cap it with `experimental.cpus: 2`. 2. Without an explicit heap ceiling, V8 sizes its max heap from the memory it detects and defers GC — in a container that reports host memory rather than the cgroup limit, RSS grows past the container limit before GC runs, and the kernel SIGKILLs the process (137). Pin the heap with `NODE_OPTIONS=--max-old-space-size=4096` so GC keeps RSS bounded. Verified locally: the full docs build completes cleanly with peak RSS ~4.9 GB (down from an unbounded ~5.3 GB+), well under the 8 GB container. Claude-Session: https://claude.ai/code/session_01KjroXa16g7LyNAP3sThibY Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2f3c641 commit 50dfa4f

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

apps/docs/next.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ const withMDX = createMDX();
77
const config = {
88
reactStrictMode: true,
99
output: 'standalone',
10+
experimental: {
11+
// The docs site prerenders 400+ MDX pages. Next spawns one static-generation
12+
// worker per CPU, and on Vercel's high-core build container that fan-out
13+
// multiplied the resident set until the build was OOM-killed (exit 137).
14+
// Cap the worker count so peak memory stays well under the container limit.
15+
cpus: 2,
16+
},
1017
typescript: {
1118
ignoreBuildErrors: false,
1219
},

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"scripts": {
88
"dev": "next dev",
9-
"build": "pnpm --filter @objectstack/spec gen:schema && pnpm --filter @objectstack/spec gen:docs && next build",
9+
"build": "pnpm --filter @objectstack/spec gen:schema && pnpm --filter @objectstack/spec gen:docs && NODE_OPTIONS='--max-old-space-size=4096' next build",
1010
"site:start": "next start",
1111
"site:lint": "next lint",
1212
"types:check": "fumadocs-mdx && next typegen && tsc --noEmit",

0 commit comments

Comments
 (0)