Skip to content

fix: replace Bun.$ shell calls with Bun.spawn for Windows compatibility#43

Merged
rhuanbarreto merged 2 commits into
mainfrom
fix/windows-shell-hang
Mar 4, 2026
Merged

fix: replace Bun.$ shell calls with Bun.spawn for Windows compatibility#43
rhuanbarreto merged 2 commits into
mainfrom
fix/windows-shell-hang

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • Replace all Bun.$ template literal shell calls with Bun.spawn() across 4 files
  • Bun.$ hangs indefinitely on Windows because the shell subprocess doesn't properly close stdin/stdout pipes, deadlocking the MCP server thread and freezing Claude Code / Cursor
  • Bun.spawn() passes commands as arrays (no shell involved) and handles pipes correctly on all platforms

Affected files

File Change
src/engine/git-files.ts Added runGit() helper; replaced 4 Bun.$ git calls
src/helpers/git.ts Replaced $git diff && git diff --cached`` (shell &&) with parallel `Bun.spawn` + `Promise.all`
src/helpers/plugin-install.ts Added run() helper; replaced claude CLI and tar shell calls
src/commands/upgrade.ts Replaced $npm install -g archgate@latest`` with Bun.spawn

Root cause

MCP tools review_context and check call git functions in git-files.ts. On Windows, Bun.$ spawns a shell subprocess that never properly closes its pipes, causing the await .text() to hang forever. Since the MCP server runs in a single async thread, this blocks all further tool calls and freezes the host (Claude Code / Cursor).

list_adrs was unaffected because it only uses readdirSync and Bun.file() — no shell calls.

What was left unchanged

  • helpers/git.ts installGit() still uses $ for brew install git and apt-get install git — these are platform-guarded (only run on macOS/Linux; Windows throws before reaching them)

Test plan

  • Verify archgate check works on Windows (was hanging before)
  • Verify review_context MCP tool responds on Windows (was hanging before)
  • Verify list_adrs still works (was unaffected, sanity check)
  • Verify archgate check still works on macOS/Linux (regression check)
  • Run bun typecheck — passes cleanly

Bun.$ template literals hang on Windows because the shell subprocess
doesn't properly close stdin/stdout pipes, causing deadlocks. This
blocks the MCP server thread and freezes Claude Code / Cursor.

Replace all Bun.$ calls with Bun.spawn (array-based, no shell) which
handles pipes correctly on all platforms.

Affected tools: review_context, check (via git-files.ts), plugin
install, and upgrade commands.
@rhuanbarreto rhuanbarreto merged commit ca33377 into main Mar 4, 2026
6 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/windows-shell-hang branch March 4, 2026 22:25
This was referenced Mar 4, 2026
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.

1 participant