[BUG] Claude Code CLI crashes with unhandled EPIPE error during normal usage

Resolved 💬 5 comments Opened Jul 2, 2025 by Nam-kyu Closed Jul 2, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.40 (Claude Code)
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
  • Terminal: iTerm2

Bug Description

Claude Code CLI unexpectedly terminates with an unhandled EPIPE error during normal usage. The error appears to be related to a broken pipe in the underlying Node.js stream handling.

Steps to Reproduce

  1. Launch Claude Code CLI
  2. Use the CLI normally for coding tasks
  3. During operation, the CLI suddenly crashes with EPIPE error

Expected Behavior

The CLI should handle pipe errors gracefully and either recover or exit cleanly with a user-friendly error message.

Actual Behavior

The CLI crashes unexpectedly with the following unhandled error:

node:events:496 
    throw er; // Unhandled 'error' event
    ^

Error: write EPIPE
    at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}

Additional Context

  • This appears to be an unhandled stream error that should be caught and handled gracefully
  • The EPIPE error typically occurs when writing to a pipe/socket that has been closed by the receiving end
  • This could be related to network connection issues, terminal window closing, or other stream interruptions
  • The error handling should prevent the CLI from crashing and provide better user feedback

View original on GitHub ↗

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