fix(docs): bound docs build memory to stop Vercel OOM (exit 137)#3221
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
os-zhuang
marked this pull request as ready for review
July 18, 2026 14:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
@objectstack/docsbuild fails on Vercel with exit 137 (SIGKILL — the build container was OOM-killed):The docs site statically prerenders 400+ MDX pages. Two things let the build's resident set climb past the ~8 GB build container:
Fix
apps/docs/next.config.mjs— addexperimental.cpus: 2to cap static-generation worker parallelism.apps/docs/package.json— runnext buildunderNODE_OPTIONS=--max-old-space-size=4096so V8 GCs and keeps RSS bounded regardless of the container's reported memory.Both changes are scoped to the docs build only; the
next buildheap 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 buildfor@objectstack/docs, 402 MDX pages) and measured peak resident memory across all node/worker processes:next build, no caps)4096onlyThe 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