[BUG] Claude Code Terminal Hang After Pasting Text
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?
Claude Code completely hangs when pasting text into the terminal. After pasting ~31 lines, the terminal became unresponsive - couldn't type, Ctrl+C and Ctrl+Q didn't work. Had to kill -9 the process.
Debugging revealed the process had written 162 MB to stdout (from pasting 31 lines) and was blocked in a write() system call. The terminal showed bracketed paste mode indicator [201~[Pasted text #1 +31 lines] and "INSERT" mode before freezing.
claude_hang_lsof.txt
claude_hang_trace.txt
mcp_playwright_lsof.txt
mcp_playwright_trace.txt
What Should Happen?
Pasting text should not generate massive output or hang the terminal. Even with large output, Claude Code should:
- Handle terminal backpressure gracefully
- Buffer or paginate output appropriately
- Remain interruptible with Ctrl+C
- Not block indefinitely on write operations
Error Messages/Logs
No error messages - terminal completely froze. Before hang, terminal showed:
[201~[Pasted text #1 +31 lines]
-- INSERT -- ⏵⏵ accept edits on (shift+tab to cycle)
Then became completely unresponsive.
Steps to Reproduce
- Start Claude Code in a project directory
- Paste approximately 30+ lines of text into the terminal
- Terminal shows bracketed paste mode:
[201~[Pasted text #1 +31 lines] - Terminal shows "INSERT" mode message
- Terminal hangs completely
Note: Could not reproduce consistently - only happened once. May be timing or content-dependent.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.37 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
What I was doing:
Working in my project directory
[201~[Pasted text #1 +31 lines]
-- INSERT -- ⏵⏵ accept edits on (shift+tab to cycle)
Then it froze completely.
What I Found
I used sample and lsof to debug the hung process before killing it:
Process was blocked writing to terminal:
PID %CPU STATE TIME
93814 0.0 S+ 3:51.79
0% CPU means it wasn't spinning - it was blocked on I/O.
Stack trace showed it was stuck in write():
8646/8842 samples (98%) in:
kevent → waiting for I/O
176/8842 samples (2%) in:
node::StreamBase::Write → write (in libsystem_kernel.dylib)
The process was blocked trying to write to the terminal.
File descriptor showed massive output:
node 93814 1u CHR 16,9 0xa251366 895 /dev/ttys009
That offset 0xa251366 = 170,000,102 bytes = ~162 MB of data written to stdout.
The Issue
When I pasted ~31 lines of text, Claude Code somehow generated 162 MB of output trying to process or display it, which completely overwhelmed the terminal buffer. The write operation blocked indefinitely, and the entire terminal became unresponsive.
Debug Data Collected
I captured full traces before killing the process:
Process info:
- PID: 93814
- Working directory:
/Users/sandman/Documents/project - Started: Nov 12 20:41:38
- Hung at: Nov 13 20:27:47 (had been running fine for ~24 hours until paste)
Stack trace: Full sample output showing 98% of time in kevent (waiting) and 2% blocked in write()
Open files: lsof showing 170 MB written to terminal device
MCP servers active:
- mcp-server-playwright (PID 44833) - trace shows it was idle during hang
Can provide full sample traces and lsof output files if needed for investigation.
Terminal Configuration
- Terminal: iTerm2
- Shell: zsh with oh-my-zsh
- Bracketed paste mode: Active (evidenced by
[201~escape sequence)
Why Ctrl+C Didn't Work
The process was blocked in a kernel system call (write), so it couldn't process signals until the write completed. Since the terminal couldn't consume 162 MB of data, the write never completed, creating a deadlock.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗