Skip to content

fix(docs): bound docs build memory to stop Vercel OOM (exit 137)#3221

Merged
os-zhuang merged 1 commit into
mainfrom
claude/vercel-ci-build-error-toc3ln
Jul 18, 2026
Merged

fix(docs): bound docs build memory to stop Vercel OOM (exit 137)#3221
os-zhuang merged 1 commit into
mainfrom
claude/vercel-ci-build-error-toc3ln

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Problem

The @objectstack/docs build fails on Vercel with exit 137 (SIGKILL — the build container was OOM-killed):

@objectstack/docs#build: ERROR command (/vercel/path0/apps/docs) pnpm run build exited (137)
Error: Command "cd ../.. && pnpm turbo run build --filter=@objectstack/docs" exited with 137

The docs site statically prerenders 400+ MDX pages. Two things let the build's resident set climb past the ~8 GB build container:

  1. Worker fan-out. Next spawns one static-generation worker per CPU. On Vercel's high-core build container that multiplies peak memory across many parallel render workers.
  2. Unbounded V8 heap. With no explicit heap ceiling, V8 sizes its max heap from the memory it detects and defers garbage collection. 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.

Fix

  • apps/docs/next.config.mjs — add experimental.cpus: 2 to cap static-generation worker parallelism.
  • apps/docs/package.json — run next build under NODE_OPTIONS=--max-old-space-size=4096 so V8 GCs and keeps RSS bounded regardless of the container's reported memory.

Both changes are scoped to the docs build only; the next build heap cap does not affect other packages (e.g. @objectstack/spec's DTS build keeps its own --max-old-space-size=12288).

Verification

Reproduced the build locally (full pnpm run build for @objectstack/docs, 402 MDX pages) and measured peak resident memory across all node/worker processes:

Configuration Build result Peak RSS
Baseline (next build, no caps) ~5.3 GB (lazy, unbounded)
Heap cap 4096 only ~4.9 GB
This PR (cpus=2 + heap cap 4096) ~4.95 GB

The build completes cleanly with the heap capped at 4 GB (no JavaScript heap out of memory), confirming the working set fits comfortably under the cap and peak RSS now stays well under the 8 GB container with margin to spare.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KjroXa16g7LyNAP3sThibY


Generated by Claude Code

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.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KjroXa16g7LyNAP3sThibY
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 18, 2026 2:39pm

Request Review

@github-actions github-actions Bot added size/xs documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file labels Jul 18, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review July 18, 2026 14:52
@os-zhuang
os-zhuang merged commit 50dfa4f into main Jul 18, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the claude/vercel-ci-build-error-toc3ln branch July 18, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants