deno
29ce0380 - fix(compile): skip Node-to-Deno arg translation in standalone binaries (#32980)

Commit
231 days ago
fix(compile): skip Node-to-Deno arg translation in standalone binaries (#32980) ## Summary - Skip Node.js-to-Deno CLI argument translation in `child_process.spawn` and `child_process.fork` when running inside a standalone (compiled) binary - Fixes an issue where compiled npm CLI tools that relaunch themselves (e.g., `@google/gemini-cli`) would get Deno flags injected into `process.argv` ## Problem When a `deno compile`d binary spawns itself via `child_process.spawn(process.execPath, args)`, Deno's `child_process` implementation detects `file === Deno.execPath()` and translates Node.js-style args (like `--max-old-space-size=4096`) into Deno CLI args (`run -A --unstable-node-globals --unstable-bare-node-builtins --unstable-detect-cjs --v8-flags=...`). The compiled binary doesn't parse these as Deno subcommands -- it puts ALL of them into `Deno.args` / `process.argv`. The app's argument parser (e.g., yargs) then rejects them: ``` Unknown arguments: A, unstable-node-globals, unstableNodeGlobals, unstable-bare-node-builtins, unstableBareNodeBuiltins, unstable-detect-cjs, unstableDetectCjs ``` ## Fix Check `Deno.build.standalone` before applying the Node-to-Deno arg translation in two places: - `buildCommand()` in `ext/node/polyfills/internal/child_process.ts` (for `spawn`) - `fork()` in `ext/node/polyfills/child_process.ts` Standalone binaries already have permissions, unstable config, and V8 flags baked into their metadata, so the translation is unnecessary and harmful. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Parents
Loading