fix: prevent V8 turboshaft WASM Zone OOM during indexing (#298, #293)#322
Merged
Conversation
Large multi-language indexes crashed with `Fatal process out of memory: Zone` on Node 22/24 (including the bundled runtime) — V8's turboshaft optimizing WASM compiler exhausts its per-compilation Zone arena while compiling tree-sitter grammars on a background thread, even with tens of GB free (the Zone is a V8-internal arena, not the JS heap). Run node with V8 `--liftoff-only`, which keeps grammar compilation on the Liftoff baseline and never reaches the optimizing tier. Delivered via the bundled launcher + a one-shot CLI re-exec guard for all other launch paths. Empirically only `--liftoff-only` stops it (`--no-wasm-tier-up` / `--no-wasm-dynamic-tiering` do not), and it must be on node's command line (setFlagsFromString / worker execArgv / NODE_OPTIONS all fail). Reproduced the exact crash with the real indexer on Node 24.16 against a 2,880-file / 18-language repo and confirmed the fix eliminates it; full suite + 7 new tests pass. Bumps to 0.9.4. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes the
Fatal process out of memory: Zonecrash that abortscodegraph index/codegraph initpartway through parsing large multi-language repos on Node 22 and 24 — including CodeGraph's own bundled Node 24 runtime. Resolves #298 and #293.Root cause
Not a system OOM. V8's "turboshaft" optimizing WASM compiler exhausts its per-compilation Zone arena (a V8-internal arena, not the JS heap) while compiling tree-sitter's large WebAssembly grammars on a background thread — so it fires with tens of GB of RAM free. Stack:
Zone::Expand → turboshaft::…WasmLoweringPhase → GenerateWasmCode → BackgroundCompileJob::Run.Fix
Run node with V8's
--liftoff-only, keeping grammar compilation on the Liftoff baseline so it never reaches the optimizing tier. Delivered two ways:scripts/build-bundle.sh) and the Windows npm-shim pass the flag directly (zero overhead for installed users), andnpx, a globally linked dev build).The flag must be on node's command line —
setFlagsFromString, workerexecArgv, andNODE_OPTIONSall fail to apply it (verified). And empirically--no-wasm-tier-up/--no-wasm-dynamic-tieringdo not prevent the crash; only--liftoff-onlydoes.Validation
Reproduced the exact issue stack with the real indexer on the shipped Node 24.16 runtime against a generated 2,880-file / 18-language repo, then confirmed the fix:
codegraph index, Node 24.16)Fatal process out of memory: Zone--no-wasm-tier-up/--no-wasm-dynamic-tiering--liftoff-only(the fix)A/B on the same fixed build toggling only the guard:
CODEGRAPH_NO_RELAUNCH=1→ 💥 crash; normal → ✅. MCP server verified working through the re-exec. Full suite (737) + 7 new tests pass.🤖 Generated with Claude Code