[BUG] Claude Code spawns processes in tight loop, saturates CPU and causes system-wide fork failed: resource temporarily unavailable
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?
Environment:
- Claude Code: 2.1.37
- Node: 20.19.6 (via Volta)
- macOS: 26.2 (25C56), Apple Silicon (ARM64)
- RAM: 48GB
Problem:
While Claude Code waits on a long-running child process (Hive query
via shell script), the node process spikes to 95-98% CPU and makes
the entire system unforkable — even ls fails with zsh: fork failed: resource temporarily unavailable.
Process/thread counts don't change significantly, and memory isn't
the issue. The system has ~14GB free.
Root cause from sample output:
The stack trace shows Array.forEach calling ProcessWrap::Spawn → posix_spawn in a tight loop with no concurrency control. 3,730 of
3,903 samples (95.6%) are stuck in posix_spawn. Claude Code appears
to be rapidly spawning processes without throttling or backpressure.
Impact:
System becomes completely unusable — cannot fork any new process
from any terminal. Only fix is force-killing the Claude node process,
which itself requires Activity Monitor since shell commands can't fork.
What Should Happen?
It shouldn't spawn processes like that
Error Messages/Logs
Steps to Reproduce
I ran claude code, then asked it to execute a shell script to run a hive query. But I have seen the same thing happening right after starting claude code and typing "/" character to list commands. It just happens at random times, and something like every 2nd session
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.37
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗