claude-code - 💡(How to fix) Fix [BUG] Bash tool hangs indefinitely on 'git remote show origin' — blocks session and remote-control clients [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45445Fetched 2026-04-09 08:05:15
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
renamed ×3labeled ×1

Error Message

The Bash tool should apply a default timeout to commands that may block on network I/O, or surface a timeout error after a reasonable wait (e.g., 30s) so the session can recover.

Error Messages/Logs

No error output. The tool call displayed:

Code Example

BashDetect base branch: git remote show origin | grep "HEAD branch" | awk '{print $NF}'
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

The Bash tool hung indefinitely while running git remote show origin | grep "HEAD branch" | awk '{print $NF}' (used to detect the base branch). This command makes a live network call to the remote even when run locally, and blocked without any timeout.

As a consequence, the entire session stopped responding — including a connected mobile remote-control client, which received no reply even after sending follow-up messages. Only pressing ESC on the desktop unblocked the session.

What Should Happen?

The Bash tool should apply a default timeout to commands that may block on network I/O, or surface a timeout error after a reasonable wait (e.g., 30s) so the session can recover.

Error Messages/Logs

No error output. The tool call displayed:

Bash — Detect base branch: git remote show origin | grep "HEAD branch" | awk '{print $NF}'

...and never completed.

Steps to Reproduce

  1. Open Claude Code in VS Code integrated terminal
  2. Connect a mobile remote-control client to the session
  3. From mobile, send a message that triggers auto-detection of the git base branch (e.g., invoking /run-autonomous)
  4. Claude Code runs git remote show origin via the Bash tool
  5. If the SSH/HTTPS connection to the remote is slow or unresponsive, the command hangs indefinitely
  6. The desktop session is blocked; the mobile client receives no response to any further messages

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.96 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux (Arch Linux)

Terminal/Shell

VS Code integrated terminal

Additional Information

  • git remote show origin queries the remote server even when run locally — unlike git remote get-url origin which reads local config only
  • A safer alternative for base branch detection that avoids network calls: git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'
  • The Bash tool has no visible timeout mechanism — any blocking command (network I/O, interactive prompts) can freeze a session indefinitely

extent analysis

TL;DR

Apply a default timeout to the Bash tool's network I/O operations to prevent indefinite hangs.

Guidance

  • Consider modifying the git remote show origin command to use a safer alternative that avoids network calls, such as git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'.
  • Implement a timeout mechanism in the Bash tool to surface a timeout error after a reasonable wait (e.g., 30s) and allow the session to recover.
  • Review the Anthropic API and Claude Code documentation to see if there are any existing timeout configuration options or APIs that can be leveraged to prevent indefinite hangs.
  • Test the modified command or timeout mechanism to ensure it works correctly in different network conditions and scenarios.

Example

# Safer alternative for base branch detection that avoids network calls
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'

Notes

The lack of a visible timeout mechanism in the Bash tool makes it prone to indefinite hangs when encountering blocking network I/O operations. Implementing a timeout mechanism or using safer alternative commands can help mitigate this issue.

Recommendation

Apply a workaround by implementing a timeout mechanism in the Bash tool or modifying the command to use a safer alternative, as the root cause of the issue is the lack of a timeout mechanism and the use of a command that can block indefinitely.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING