fix(windows): pass stdin=DEVNULL to git/svn subprocesses to prevent MCP hang (closes #401)#425
Open
dannymn wants to merge 1 commit intotirth8205:mainfrom
Open
fix(windows): pass stdin=DEVNULL to git/svn subprocesses to prevent MCP hang (closes #401)#425dannymn wants to merge 1 commit intotirth8205:mainfrom
dannymn wants to merge 1 commit intotirth8205:mainfrom
Conversation
…CP hang Closes tirth8205#401. PROBLEM On Windows, when CRG runs as an MCP server (stdio transport, e.g. via Claude Code or Cursor), the git/svn subprocesses spawned by tools/context.py, changes.py, and incremental.py inherit the parent's stdin — which is bound to the MCP request pipe. The child process blocks reading from this pipe (Windows console-handle behavior) and never exits. The MCP tool call (get_minimal_context_tool, detect_changes_tool, get_changed_files, etc.) hangs indefinitely. From the user's view Claude Code freezes; only ESC breaks out. `claude doctor` itself times out spawning CRG for the same reason. REPRO Reproduces on Claude Code 2.1.126 + CRG 2.3.2 + FastMCP 2.14.7 + Windows 11. Server-side test (printf init+list | code-review-graph serve) returns correctly in ~1.5s — the subprocess hang is invisible at that level because no git call fires for the bare initialize handshake. FIX Add stdin=subprocess.DEVNULL to every subprocess.run([...git...]) and subprocess.run([...svn...]) call so the child gets an empty stdin instead of inheriting the MCP pipe. POSIX-safe — DEVNULL works identically on Linux/macOS (no behavioural change there). 14 call sites patched across 3 files: - code_review_graph/tools/context.py (2 git calls) - code_review_graph/changes.py (1 git, 1 svn) - code_review_graph/incremental.py (6 git, 4 svn) VERIFIED After this patch: mcp__code-review-graph__get_minimal_context_tool returns in <2s with full graph context on Windows 11 + Claude Code 2.1.126. Before: hangs >60s, user must ESC. Likely also addresses related Windows hang reports: tirth8205#46, tirth8205#136, tirth8205#189.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #401
Problem
On Windows, when CRG runs as an MCP server (stdio transport, e.g. via Claude Code or Cursor), the
git/svnsubprocesses spawned bytools/context.py,changes.py, andincremental.pyinherit the parent's stdin — which is bound to the MCP request pipe. The child blocks reading from this pipe (Windows console-handle behavior) and never exits. The MCP tool call (get_minimal_context_tool,detect_changes_tool,get_changed_files, etc.) hangs indefinitely. From the user's view Claude Code freezes; only ESC breaks out.claude doctoritself times out spawning CRG for the same reason.Repro
Reproduces on Claude Code 2.1.126 + CRG 2.3.2 + FastMCP 2.14.7 + Windows 11.
Direct server-side stdio test (
printf '<init>\n<list>\n' | code-review-graph serve) returns the full tools list in ~1.5s — the subprocess hang is invisible at that level because the bareinitializehandshake fires no git call. Only when an actual MCP tool callsget_minimal_context_tool → _has_git_changes → subprocess.run(["git", ...])does the inherited stdin pipe deadlock the child.Fix
Add
stdin=subprocess.DEVNULLto everysubprocess.run([...git...])andsubprocess.run([...svn...])call so the child gets an empty stdin instead of inheriting the MCP pipe. POSIX-safe —DEVNULLworks identically on Linux/macOS (no behavioural change there).14 call sites patched across 3 files:
code_review_graph/tools/context.py(2 git calls)code_review_graph/changes.py(1 git, 1 svn)code_review_graph/incremental.py(6 git, 4 svn)Verified
After this patch:
mcp__code-review-graph__get_minimal_context_toolreturns in <2s with full graph context on Windows 11 + Claude Code 2.1.126.Likely also addresses related Windows hang reports: #46, #136, #189.
Why now
The issue was reported 2026-04-29 (#401). I hit it head-on while integrating CRG with Claude Code on a real project (DreamJob.AI) and traced it through:
claude doctoralso hangs (exit 143)tasklistshows multiple zombiegit/code-review-graphprocesses after each hang attempttools/context.pyrevealed the missingstdin=subprocess.DEVNULLon the subprocess.run callsHappy to iterate on review feedback. Tested locally for 30+ MCP tool calls without a single hang after the patch.