Skip to content

URGENT fix(build): route ChatGPT Web MCP bundle through runBuildTool (Windows/Node 24 build crash) v.50/.51 - #11706

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.51from
jonlwheat2-gif:fix/prepublish-npx-cmd-spawn
Aug 30, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.51from
jonlwheat2-gif:fix/prepublish-npx-cmd-spawn

Conversation

@jonlwheat2-gif

Copy link
Copy Markdown
Contributor

What was broken

npm run build:cli (scripts/build/prepublish.ts) crashes on Node ≥ 20 on Windows while bundling the ChatGPT Web (Codex) MCP bridge. The crash killed the CLI packaging step, so a user building from the source-only release ZIP (no prebuilt dist/) cannot produce a working global install.

Red evidence (Node v24.18.0, Windows, v3.8.50 source ZIP):

🔨 Bundling ChatGPT Web (Codex) MCP bridge...
    '--platform=node',
    '--packages=external',
    '--format=esm',
    '--outfile=dist/open-sse/vendor/codex-chatgpt-web/adapters/chatgpt-web/mcp-server.js'
  ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 0,            ← child process never spawned
  ...
}

Node.js v24.18.0

Root cause

scripts/build/prepublish.ts:326 (old) called execFileSync(NPX_BIN, ...) directly — NPX_BIN is "npx.cmd" on win32. On Node ≥ 20, spawning a .cmd shim without shell: true throws EINVAL (CVE-2024-27980 spawn hardening). This is the exact failure mode the file's own header comment documents (lines 46–52), which is why runBuildTool() was introduced — it resolves the tool's JS entry and runs it with process.execPath, no shim, no shell. This one call site was missed by that refactor and is the only remaining raw NPX_BIN spawn in the file.

The fix (this PR)

scripts/build/prepublish.ts — route that one call through the existing runBuildTool():

Line Before After
326 execFileSync(NPX_BIN, [ runBuildTool("esbuild", "esbuild", [
328–336 ["esbuild", "...mcp-server.ts", ...] same args, unchanged
337 { cwd: ROOT, stdio: "inherit" } same options, unchanged

Full diff (6 lines changed, 3 added / 3 removed): the esbuild args and options are byte-identical; only the spawn mechanism changes.

What was tested

  • Red: prepublish.ts crashes at this exact step on Node 24/Windows before the change (crash log above).
  • Green: with the change, the full npm run build:cli completes — dist/server.js, dist/BUILD_SHA, and dist/open-sse/vendor/codex-chatgpt-web/adapters/chatgpt-web/mcp-server.js are all produced, and the resulting global install boots (omniroute --version → 3.8.50, server serves on :20128).
  • Gates on this branch: eslint on the changed file → 0 errors; npm run typecheck:core → clean; check:changelog-integrity → OK vs origin/release/v3.8.51.

Scope

2 files, surgical:

  • scripts/build/prepublish.ts (1 call site)
  • changelog.d/fixes/11704-prepublish-npx-cmd-win32.md (fragment)

Fixes #11704.

prepublish.ts spawned npx.cmd raw to bundle the codex-chatgpt-web MCP
bridge. On Node >= 20 spawning a .cmd shim without a shell throws EINVAL
(CVE-2024-27980 hardening), crashing the CLI build on Windows. Route it
through runBuildTool() like every other esbuild/tsc invocation in the
file. Fixes cheaper-inference#11704.
@jonlwheat2-gif jonlwheat2-gif changed the title fix(build): route ChatGPT Web MCP bundle through runBuildTool (Windows/Node 24 build crash) fix(build): route ChatGPT Web MCP bundle through runBuildTool (Windows/Node 24 build crash) v.50/.51 Aug 26, 2026
@jonlwheat2-gif jonlwheat2-gif changed the title fix(build): route ChatGPT Web MCP bundle through runBuildTool (Windows/Node 24 build crash) v.50/.51 URGENT fix(build): route ChatGPT Web MCP bundle through runBuildTool (Windows/Node 24 build crash) v.50/.51 Aug 26, 2026
diegosouzapw and others added 2 commits August 29, 2026 01:48
Regression for cheaper-inference#11704: prepublish.ts must not spawn npx.cmd to
bundle the Codex ChatGPT Web MCP bridge (EINVAL on Node >= 20/Windows).

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 38a2966 into cheaper-inference:release/v3.8.51 Aug 30, 2026
14 of 15 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…(Windows/Node 24 build crash) v.50/.51 (cheaper-inference#11706)

Confirmed the bug is real and unfixed on the current tip before merging: `scripts/build/prepublish.ts` line 332 was still calling `execFileSync(NPX_BIN, ...)` directly (raw win32 npx.cmd spawn), the exact CVE-2024-27980 shim pattern the file's own header warns about. Root cause, fix, and evidence match — routing through the existing `runBuildTool()` helper. Thanks for catching the one call site the earlier refactor missed.
@jonlwheat2-gif
jonlwheat2-gif deleted the fix/prepublish-npx-cmd-spawn branch September 30, 2026 15:39
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.

fix(nodejs): prepublish.ts crashes on Node >=20 building ChatGPT Web Codex MCP bridge (raw npx.cmd spawn, EINVAL)

2 participants