Skip to content

fix: pin frontend dev server heap ceiling (#91) - #93

Merged
AntoineToussaint merged 2 commits into
mainfrom
fix/frontend-dev-heap-ceiling
Aug 3, 2026
Merged

fix: pin frontend dev server heap ceiling (#91)#93
AntoineToussaint merged 2 commits into
mainfrom
fix/frontend-dev-heap-ceiling

Conversation

@AntoineToussaint

Copy link
Copy Markdown
Contributor

Closes #91.

Summary

  • The nextjs service agent starts the frontend with npm run dev (run logs: > npm run prepare:frontend && next dev -p <port>), so the dev process inherits Node's ~2 GB old-space default — the OOM GC lines show it dying at a ~2048 MB ceiling (1944.0 (2060.0) MB), well below the 4288 MB the same Node reports unconstrained. Nothing in the repo sets a limit, so under Turbopack + reactCompiler + transpiled plugin workspaces the dev compiler grows past that ceiling and OOMs within minutes, taking the port with it and reading as an unreachable site after a successful start.
  • Root cause is the inherited ceiling, not a repo-set cap: the dev script is the one in-repo layer the agent runs, so pinning an explicit --max-old-space-size=8192 there makes the ceiling asserted rather than inherited by every consumer following the documented dogfood command — instead of an invisible NODE_OPTIONS on each person's shell.
  • Scope kept tight: reactCompiler and transpilePackages are deliberate (plugin HMR, product decision); reducing them would regress behavior, so this only lifts the ceiling.

Test plan

  • node --test module/tools/base-integrity.test.mjs — 20/20 pass, including "the committed canonical manifest matches the tree it ships with" (manifest regenerated via base-integrity.mjs gen for the edited base package.json + new test file).
  • New scripts/dev-heap-ceiling.test.mjs (vitest pure project) asserts the dev script pins an explicit old-space ceiling above the inherited 2048 MB default and applies it to next dev. Verified the assertions pass against the real package.json (deps not installed in this worktree, so validated with plain Node rather than a full npm ci).

Notes for the reviewer

  • The issue's testing surface asks for a 10-minute idle HTTP soak. That can't live in CI, so the committed test instead mechanically prevents regression to the inherited ~2 GB ceiling. A live soak against codefly run service --env local-dogfood is the manual confirmation.
  • 8192 is a generous headroom ceiling (matches the value that was already stabilizing runs), not a tuned minimum — --max-old-space-size is a cap, not a reservation.

🤖 Generated with Claude Code

AntoineToussaint and others added 2 commits August 3, 2026 07:20
The nextjs agent starts the dev server with `npm run dev`, so the dev
process inherits Node's ~2 GB old-space default. Under Turbopack +
reactCompiler + transpiled plugin workspaces the dev compiler grows past
that ceiling and OOMs within minutes, taking the port with it and
presenting as an unreachable site after a successful start.

Set an explicit --max-old-space-size on the `next dev` invocation — the
one in-repo layer the agent runs — so the ceiling is asserted rather than
inherited by every consumer following the documented dogfood command.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address review of the dev heap ceiling:

- Append to NODE_OPTIONS instead of replacing it, so any options the
  codefly runtime injects into the dev process (tracing loaders, source
  maps) survive rather than being clobbered by the inline assignment.
- Replace the brittle exact-adjacency assertion with a behavioral test:
  run the dev script's real env prefix with a probe standing in for
  `next dev` and assert the process sees both a pre-set NODE_OPTIONS and
  the appended ceiling. This fails on the old replacing form.
- Resolve package.json via import.meta.dirname; the previous new URL()
  form threw under the vitest transform.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AntoineToussaint
AntoineToussaint merged commit be406f5 into main Aug 3, 2026
4 checks passed
@AntoineToussaint
AntoineToussaint deleted the fix/frontend-dev-heap-ceiling branch August 3, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend dev server dies with JavaScript heap out of memory ~2 minutes after start

1 participant