Skip to content

Fix: Ensure compatibility with Node.js >= 25 and Bun#222

Open
Cleboost wants to merge 1 commit into
colbymchenry:mainfrom
Cleboost:node-26
Open

Fix: Ensure compatibility with Node.js >= 25 and Bun#222
Cleboost wants to merge 1 commit into
colbymchenry:mainfrom
Cleboost:node-26

Conversation

@Cleboost
Copy link
Copy Markdown

@Cleboost Cleboost commented May 20, 2026

Context & Problem

Node.js 25.x (and newer versions relying on recent V8 releases) introduced a regression in the new V8 Turboshaft WebAssembly compiler pipeline. During heavy WASM compilation workloads—such as
compiling tree-sitter grammars—the engine hits a native allocator limit and crashes with a fatal process out-of-memory error: Fatal process out of memory: Zone .

Previously, CodeGraph had a hard blocking check on Node.js versions >= 25 to prevent these unexpected mid-indexing crashes. However, this caused two issues:

  1. It blocked users running recent Node.js releases even if they wanted to bypass or run safely.
  2. It incorrectly blocked users running Bun (since Bun's Node compatibility layer advertises a Node version higher than 25 in process.versions.node ), even though Bun uses WebKit's JavaScriptCore
    (JSC) and is entirely unaffected by V8-specific bugs.

Proposed Changes

This PR introduces a robust, transparent compatibility layer for Node.js >= 25 and Bun without breaking backward compatibility:

  1. Bun Auto-Detection:
    • Skips the version compatibility block entirely if 'bun' in process.versions is detected. This allows commands like bun cli to run natively and safely.
  2. Transparent Node.js Respawning:
    • For Node.js >= 25 runtimes, the script now dynamically checks if the --no-turboshaft V8 flag is active in process.execArgv .
    • If missing (and the unsafe override env variable is not set), the CLI transparently spawns a child process of itself prepended with --no-turboshaft . This disables V8's problematic Turboshaft
    pipeline and falls back to the highly stable TurboFan compiler tier for WebAssembly, preventing the Zone allocator crash entirely.
    • The parent process waits for the child and inherits its exit status code.

fix #183

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.

Support Node.js version: 26.1.0

1 participant