Unhandled EPIPE Error in Node.js Socket Write Operation
Status Closed — duplicate
Maintainer reply ✓ Yes — dicksontsai
Activity 15 comments · opened Jul 1, 2025 · closed Jul 3, 2025
💡 Likely answer: A maintainer (dicksontsai, collaborator)
responded on this thread — see the highlighted reply below.
Bug Description
Claude exits with the below 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'
}
Node.js v22.16.0
Environment Info
- Platform: darwin
- Terminal: Apple_Terminal
- Version: 1.0.38
- Feedback ID: a812f9dc-9adc-40bd-801e-3ba1f8da06b6
Errors
[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n at genericNodeError (node:internal/errors:983:15)\n at wrappedFn (node:internal/errors:537:14)\n at checkExecSyncError (node:child_process:882:11)\n at execSync (node:child_process:954:15)\n at WI (file:///Users/naveen/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:701:3921)\n at file:///Users/naveen/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:9038\n at Q (file:///Users/naveen/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n at SX (file:///Users/naveen/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:8184)\n at K_ (file:///Users/naveen/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:7265)\n at O9 (file:///Users/naveen/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:11432)","timestamp":"2025-07-01T10:01:17.860Z"},{"error":"RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded\n at Socket.onChildStdout (node:child_process:481:14)\n at Socket.emit (node:events:518:28)\n at Socket.emit (node:domain:489:12)\n at addChunk (node:internal/streams/readable:561:12)\n at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n at Readable.push (node:internal/streams/readable:392:5)\n at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)","timestamp":"2025-07-01T10:01:18.392Z"}]
15 Comments
Getting the same error while claude is editing files
Same, getting same error.
Did this suddenly start happening since yesterday? Cant get any work done!
FWIW: I was seeing this error consistently, but I was able to overcome it by deleting all hooks. I had a post-tool hook that was running prettier/lint.
Nope. Not hooks for me atleast. i deleted the entire folder and it still failed 40 min in. It did extend my sessions, but still failing when writing files. This is a critical bug that is essentially stopping use of the platform.
Downgrading to 37 fixed the issue.
I also tried to delete all hooks and I'm still getting it on Claude 1.0.40 with Node.js v22.12.0 on Mac 15.6 Beta
I think the root problem is that claude-code versions 1.0.38 through 1.0.40 switched to Undici keep-alive sockets, and on Node 22 that means a write can hit a socket the server or proxy already closed, triggering EPIPE.
I think the two quickest ways to avoid the crash are:
1. Pin to 1.0.37
This version doesn’t reuse sockets, so the broken-pipe path disappears.
2. Stay on 1.0.40 but disable keep-alive each run
That forces per-request sockets, giving the same safety as 1.0.37 without downgrading.
@mkwatson :I upgarded back to 40 yesterday using your tip, but it still had issues with launched subgents bugging out. With 37, i was running into insufficient memory errors and crashing :/. Trying out 41 now. Hopefully the issues have been fixed! Would love to re-deploy the hooks setup.
same issue in 41 confirmed - ✗ Auto-update failed · Try claude doctor or npm i -g @anthropic-ai/claude-code
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'
}
Node.js v22.16.0
Back to 37 it is! Atleast it let me work for sometime. lol.
@naveensoman I've had no issues since pinning the version to 1.0.37
Its pretty much doing what I want. Except that when it hits the boundary of its allocated memory(not entirely sure, diagnosing it now), it freaks out and quits. Try launching a tonne of subagents that use a lot of memory.
Seems to be the same as #2834 which seems to have some traction on getting a fix soon.
Yes, the fix will be a part of v1.0.42. Sorry for the inconvenience.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.