[BUG] CLI hangs indefinitely on simple queries (macOS M1, v2.1.37)

Resolved 💬 3 comments Opened Feb 9, 2026 by romulus-silvius Closed Feb 13, 2026

Bug Report: Claude Code CLI Hangs on Simple Queries (macOS M1)

Submit to: https://github.com/anthropics/claude-code/issues

---

Bug Description

Claude Code CLI hangs indefinitely on even the simplest queries when using -p (print mode). Process never completes or exits — requires manual kill.

Environment

| Component | Version |
|-----------|---------|
| Claude Code | 2.1.37 |
| macOS | 25.2.0 (Darwin Kernel) |
| Architecture | Apple Silicon M1 (arm64) |
| Node.js | v22.22.0 |
| Installation | Global via curl -fsSL https://code.claude.com/install.sh \| sh |

Reproduction Steps

Test 1: Simple Query

cd ~/.openclaw/workspace
claude -p "What is 2+2? Reply with just the number."

Expected: Returns "4" in ~5 seconds

Actual: Hangs indefinitely, no output, no error, never exits

Duration tested: 30+ seconds before manual kill

---

Test 2: With Permission Bypass

claude --dangerously-skip-permissions -p "What is 2+2?"

Expected: Skips permission prompts, returns result

Actual: Still hangs, same behavior as Test 1

---

Test 3: With MCP Disabled

Config: ~/.claude/settings.json

{"mcp": {"enabled": false}}
claude -p "test query"

Expected: Bypasses MCP initialization, completes normally

Actual: Still hangs, config had no effect

---

Debug Logs Analysis

Location: ~/.claude/debug/*.txt

Pattern observed in all sessions:

[DEBUG] [STARTUP] Loading MCP configs...
[DEBUG] Found 0 plugins (0 enabled, 0 disabled)
[DEBUG] [claudeai-mcp] Checking gate (cached)...
[DEBUG] [claudeai-mcp] Gate returned: true
[DEBUG] [claudeai-mcp] Fetching from https://api.anthropic.com/v1/mcp_servers?limit=1000
[DEBUG] [claudeai-mcp] Fetched 1 servers
<PROCESS HANGS — never proceeds beyond this point>

Hypothesis: Process gets stuck after fetching MCP servers, never proceeds to prompt execution.

---

Interactive Mode Test

Attempt: Use expect script to test interactive mode

#!/usr/bin/expect -f
spawn claude
expect ">"
send "What is 2+2?\r"
expect ">"
send "/exit\r"
expect eof

Result:

Accessing workspace: /Users/romulus/.openclaw/workspace

Quick safety check: Is this a project you created or one you trust?
❯ 1. Yes, I trust this folder
  2. No, exit
<HANGS waiting for user input>

Observation: Interactive mode shows workspace trust dialog, but -p flag should skip this according to docs.

---

Additional Context

Similar Issues Found

This appears related to existing open issues:

  • #19060: "CLI freezes with 'No messages returned' error - never recovers"
  • #6823: "Claude CLI randomly/predictably freezes on Windows"
  • #13224: "Claude Code hangs or freezes during execution with no recovery"
  • #12014: "Claude Code CLI freezes"

What We Tried

✅ Clean install — No improvement

✅ Disabled MCP in config — No effect

✅ Used --dangerously-skip-permissions — Still hangs

✅ Tested multiple query types — All hang

✅ Checked for conflicting processes — None found

✅ Reviewed debug logs — MCP fetch completes, then hangs

❌ None of these resolved the issue

---

Impact

Severity: Critical for automated workflows

Use case: Building automated coding assistant (OpenClaw integration)

Current status: CLI completely unusable

Workaround: None found — considering browser interface instead

---

Expected Behavior

claude -p "query" should:

  1. Initialize (including MCP if enabled)
  2. Process the query
  3. Return response to stdout
  4. Exit cleanly with code 0

Within reasonable timeout: 5-30 seconds depending on query complexity

---

Suggested Fixes

Short-term

1. Better error handling:

  • Catch unhandled promise rejections (as noted in #19060)
  • Add timeout with clear error message
  • Exit with non-zero code on failure

2. MCP initialization:

  • Add timeout for MCP server fetch
  • Provide flag to disable MCP completely (--no-mcp?)
  • Make MCP initialization failures non-fatal

3. Debug mode:

  • Add --verbose output to show where hang occurs
  • Improve logging for MCP initialization steps

Long-term

4. Fix root cause:

  • Investigate why MCP fetch completion doesn't proceed
  • Ensure all async operations have proper error boundaries
  • Add health checks for critical initialization steps

---

Workarounds Attempted

None successful.

Current plan:

  • Use Claude Code browser interface (code.claude.com) instead
  • Or use OpenRouter API directly
  • Wait for CLI fix in future release

---

Additional Information

Authentication: Logged in successfully via claude /login

Network: No firewall blocking Anthropic APIs

Previous versions: First install, no prior versions tested

Other tools: No conflicts with other Node.js CLIs

---

Logs Available

Can provide:

  • Full debug logs from ~/.claude/debug/
  • Process traces (if helpful)
  • Network captures (if needed)

---

Request

This bug makes the CLI completely unusable for our workflow.

Is there:

  • A known fix in progress?
  • A workaround we haven't tried?
  • A beta/dev version with this resolved?
  • Timeline for a patch?

Happy to provide additional debugging info if it helps resolve this.

---

Thank you for maintaining Claude Code!

Despite this issue, we're excited about the potential and looking forward to a stable CLI experience.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗