Skip to content

Set NODE_OPTIONS to increase V8 heap for large monorepos#1649

Open
davidwinder-gyde wants to merge 3 commits intogithub:mainfrom
gyde-internal:set-node-options-for-pnpm-heap
Open

Set NODE_OPTIONS to increase V8 heap for large monorepos#1649
davidwinder-gyde wants to merge 3 commits intogithub:mainfrom
gyde-internal:set-node-options-for-pnpm-heap

Conversation

@davidwinder-gyde
Copy link
Copy Markdown

Problem

The updater container has an 8GB memory limit (UPDATER_MAX_MEMORY), but Node.js V8 auto-scaling caps heap at ~2GB for containers above 4GB. This leaves ~6GB of allocated container memory unused while pnpm install crashes with "JavaScript heap out of memory" on large monorepos during lockfile regeneration.

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

This affects any pnpm/npm monorepo with 100+ workspace packages where the lockfile regeneration exceeds 2GB of heap. The failure is deterministic — the same dependency update fails every time with no workaround available to users.

Fix

Add NODE_OPTIONS=--max-old-space-size=4096 to the envVars array in updater-builder.ts. This allows V8 to use up to 4GB (half the container limit), leaving room for Ruby and other processes running in the container.

Why this value

  • The container memory limit is 8GB (UPDATER_MAX_MEMORY)
  • Ruby (Dependabot updater logic) uses ~500MB
  • 4GB for Node.js + 500MB for Ruby = ~4.5GB, well within the 8GB limit
  • V8's default ~2GB cap is not an intentional choice — it's an artifact of V8's auto-scaling formula that doesn't account for the container having 8GB available

Testing

  • npm run lint-check — passes
  • npm run format-check — passes
  • npm run test — 121 passed, 17 skipped (same as main)
  • npm run package — dist rebuilt and committed

Related

The updater container has an 8GB memory limit (UPDATER_MAX_MEMORY),
but Node.js V8 auto-scaling caps heap at ~2GB for containers above
4GB. This leaves ~6GB of allocated container memory unused while
pnpm/npm crash with "JavaScript heap out of memory" on large
monorepos (100+ workspace packages) during lockfile regeneration.

Set NODE_OPTIONS=--max-old-space-size=4096 to allow V8 to use up
to 4GB (half the container limit), leaving room for Ruby and other
processes.

Fixes: dependabot/dependabot-core#14596
@davidwinder-gyde davidwinder-gyde requested a review from a team as a code owner April 1, 2026 14:28
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.

pnpm: JavaScript heap out of memory on large monorepos (NODE_OPTIONS not set in updater container)

1 participant