[BUG] Claude code randomly hangs after throwing a bunch of spawn exceptions

Resolved 💬 3 comments Opened Jun 16, 2025 by jaysonsantos Closed Jul 19, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.24
  • Operating System: macos 15.5
  • Terminal: itemr2

Bug Description

<!-- A clear and concise description of the bug -->
After a while using claude, usually with something where it has to iterate for a few minutes compiling, testing, and coming back it starts throwing spawn exceptions.

Steps to Reproduce

Hard to say how to reproduce, I could not find any pattern.

Actual Behavior

Exception thrown

Error: spawn EBADF
    at ChildProcess.spawn (node:internal/child_process:420:11)
    at spawn (node:child_process:762:9)
    at file:///Users/jayson.reis/.asdf/installs/nodejs/20.18.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:138:160626
    at ck1 (file:///Users/jayson.reis/.asdf/installs/nodejs/20.18.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:138:161121)
    at file:///Users/jayson.reis/.asdf/installs/nodejs/20.18.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:138:161354
    at Array.forEach (<anonymous>)
    at ChildProcess.Y (file:///Users/jayson.reis/.asdf/installs/nodejs/20.18.1/lib/node_modules/@anthropic-ai/claude-code/cli.js:138:161289)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1104:16) {
  errno: -9,
  code: 'EBADF',
  syscall: 'spawn'
}

and right before exiting the process without any other message, this is the last output

<img width="1721" alt="Image" src="https://github.com/user-attachments/assets/a77e3502-9830-4bae-ae44-108fdcdaedad" />

View original on GitHub ↗

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