[BUG] First prompt freezes TUI ~40–60s (event-loop stall, ~2.6GB RSS) even with --safe-mode
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
Claude Code 2.1.237 blocks the main thread for ~40–60 seconds on the first prompt of every new process. The TUI looks dead (no redraw, Ctrl+C ignored). The process is not stuck forever: it recovers and answers if you wait. This reproduces with --safe-mode, no user MCP, Haiku, and a one-file git repo.
Environment
• Claude Code 2.1.237 (npm-local, ~/.claude/local, @anthropic-ai/claude-code)
• OS: Linux 7.0.0-29-generic x86_64
• Install method: local (installMethod: local)
• Binary: bundled claude.exe (Bun)
• RAM: 62 GB (not memory-constrained)
Reproduction
1 │mkdir /tmp/cc-stall && cd /tmp/cc-stall && git init
2 │echo x > f.txt
3 │claude --safe-mode
4 │# type: hi
Non-interactive equivalent (same stall, then a reply):
1 │claude --safe-mode -p 'Reply with exactly the word pong and nothing else.' \
2 │ --model haiku --output-format text --debug-file /tmp/cc-stall.log
Expected
First prompt starts streaming within a couple of seconds. Terminal stays responsive.
Actual
• TUI freezes immediately after the first prompt
• Process at ~100% CPU, RSS ~2.5–3.5 GB
• Ctrl+C / SIGTERM often ignored until the stall ends
• After ~40–60s the reply appears (pong in print mode)
• Every new process pays this cost again (not a one-time warmup)
What it is not
Ruled out by isolation:
┌──────────────────────────────────────────────┬────────────────────────────────────────────────────────────┐
│ Variable │ Result │
├──────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ User MCP (Atlassian/Bitbucket) │ Stall with --strict-mcp-config and empty MCP config │
├──────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ opus[1m] / always-thinking │ Stall with --model haiku │
├──────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ Large workspace / nested git repos │ Stall in a one-file repo under /tmp │
├──────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ Session history / temp files │ Stall on a fresh session after clearing ~/.claude/projects │
├──────────────────────────────────────────────┼────────────────────────────────────────────────────────────┤
│ User config (CLAUDE.md, plugins, hooks, MCP) │ Stall with --safe-mode │
└──────────────────────────────────────────────┴────────────────────────────────────────────────────────────┘
--safe-mode log confirms Claude.ai MCP connectors are off ([claudeai-mcp] Disabled in safe mode) and it still stalls.
Debug evidence
From --safe-mode -p + --debug-file (Haiku, empty git dir). Wall clock 45s, then pong:
1 │[DEBUG] [claudeai-mcp] Disabled in safe mode
2 │[DEBUG] Sending 12 skills via attachment (initial)
3 │[DEBUG] [API:timing] dispatching to firstParty model=claude-haiku-4-5-20251001
4 │# ~41s gap, no log lines
5 │[DEBUG] [API:timing] first byte after 40832ms
6 │[WARN] [event-loop-stall] blocked for 40808ms (expected 200ms, actual 41008ms). Total stalls: 1, cumulative: 40808ms [likely sleep/wake] cpu=40899ms majflt=0 rss=2646MB heap=896MB ext=270MB
7 │[DEBUG] [API:timing] first byte after 1122ms
The silence is between Sending 12 skills via attachment (initial) and the next API dispatch. CPU time ≈ wall time, so this is synchronous main-thread work, not I/O wait. The stall detector’s [likely sleep/wake] tag is misleading here.
Same pattern without --safe-mode: 50–64s, RSS up to ~3.5 GB. Interactive sessions that are killed during the stall show 0 input/output tokens and TUI FPS ~0.1.
What Should Happen?
First prompt starts streaming within a couple of seconds. Terminal stays responsive.
Error Messages/Logs
Steps to Reproduce
1 │mkdir /tmp/cc-stall && cd /tmp/cc-stall && git init
2 │echo x > f.txt
3 │claude --safe-mode
4 │# type: hi
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.237
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗