Fix: Ensure compatibility with Node.js >= 25 and Bun#222
Conversation
|
Also hoping to get this one in as I primarily only use bun making this incompatible, and the latest change didn't fix it. |
|
Thanks for digging into this, @Cleboost — the Bun-vs-V8 distinction and the respawn idea were good instincts. It's been overtaken by changes to how CodeGraph is packaged and how the crash is handled, so the specific approach here is no longer the right fit. 1. The respawn mechanism already exists on main — 2. The version block barely fires for real users anymore. The published package is a thin installer ( 3. The Bun-skip would make things worse, not better. Closing as superseded — appreciate the effort and the clear writeup. 🙏 |
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:
(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:
• Skips the version compatibility block entirely if 'bun' in process.versions is detected. This allows commands like bun cli to run natively and safely.
• 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 Turboshaftpipeline 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