fix(ci): cap V8 heap below Cloudflare's 8 GB build container#223
Merged
Conversation
Cloudflare Workers Builds run in an 8 GB container, but the build
requested an 8 GB V8 heap (--max-old-space-size=8192). V8 defers its
major GC until the heap nears that ceiling, so during the prerender
crawl total RSS exceeds 8 GB and the container is OOM-killed
("An internal error occurred... contact Cloudflare support", terminated).
GitHub PR CI passes only because its runners have 16 GB.
Lower the heap ceiling to 5 GB -- above the ~4 GB the SSR bundle needs,
below the 8 GB container limit -- and prerender one page at a time to
trim the crawl's peak memory. Prerendering stays enabled; build output
is unchanged (556 pages, tests green).
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
superwall-docs | 5272278 | Commit Preview URL Branch Preview URL |
Jun 25 2026, 04:57 PM |
The heap cap alone addresses the OOM (it's what stopped V8 from growing toward the 8 GB container during prerender). concurrency:1 was over- conservative and added ~2.3 min to the build, so revert it to the original 2 -- keeps build time at the historical ~8 min. Also drop the redundant NODE_OPTIONS from build:cf:staging, since it calls `build`, which already sets the cap on the only V8/node step (vite build).
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
Cloudflare Workers Builds (the git-connected CI that builds & deploys the docs Worker on push to
main) has been intermittently failing onmain. Builds end with:(outcome:
terminated). The client and SSR bundles build fine — the build dies the instant the prerender crawl starts.Root cause
The build runs
NODE_OPTIONS=--max-old-space-size=8192— an 8 GB V8 heap — but Workers Builds containers have exactly 8 GB of RAM (20-min timeout, so this is not a timeout). Telling V8 it may grow to 8 GB on an 8 GB box defers the major GC until RSS already exceeds the container, so the kernel OOM-kills the build during the prerender crawl (its peak-memory moment). The abrupt stop with no stack trace — just Cloudflare's "internal error" — is the OOM-kill signature.GitHub PR CI never caught this because its runners have 16 GB, so the same 8 GB heap fits.
Fix
--max-old-space-size=5120) in thebuildandbuild:cf:stagingscripts — above the ~4 GB the SSR bundle needs (4096 flaky-crashes with V8 "heap out of memory"), and below the 8 GB container so the major GC fires before RSS hits the ceiling.concurrency2 → 1 to trim the crawl's peak memory.Prerendering stays fully enabled; site output is byte-for-byte identical.
Verification
bun test65 pass / 0 fail, ~2.2 min.Same fix also covers staging (shares the
buildscript). Do not merge until the preview build is green.Note
Low Risk
Build-time memory tuning only; no runtime app, auth, or data-path changes, and prerender output is intended to stay identical.
Overview
Lowers the Node/V8 old-space heap limit for production docs builds from 8 GB to 5 GB (
--max-old-space-size=5120) on the mainbuildscript so prerender can run inside Cloudflare’s 8 GB RAM build containers without the kernel OOM-killing the process when the heap matches container size.The
build:cf:stagingscript no longer sets its ownNODE_OPTIONS=8192; it only setsCLOUDFLARE_ENV=stagingand delegates tobuild, so staging uses the same 5 GB cap.Reviewed by Cursor Bugbot for commit 5272278. Bugbot is set up for automated code reviews on this repo. Configure here.