Unhandled EPIPE Error Causing Node.js Application Crash
Resolved 💬 30 comments Opened Jul 1, 2025 by pauloportella Closed Jul 3, 2025
💡 Likely answer: A maintainer (dicksontsai, collaborator)
responded on this thread — see the highlighted reply below.
Bug Description
App is crashing
node:events:485
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 v24.0.1
Environment Info
- Platform: darwin
- Terminal: tmux
- Version: 1.0.39
- Feedback ID: 1b92f826-dc88-45a5-ba4d-f8504cb473bc
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:891:11)\n at execSync (node:child_process:963:15)\n at JI (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n at file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:9038\n at Q (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n at _X (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:8184)\n at H_ (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:7265)\n at T9 (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:623:11432)","timestamp":"2025-07-01T23:01:59.462Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n at wY (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1489:1184)\n at file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1489:912\n at Array.map (<anonymous>)\n at AH (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1489:903)\n at Object.renderToolResultMessage (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1495:933)\n at jT2 (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1958:3255)\n at ZU (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:65:19799)\n at UP (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:42556)\n at wP (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38105)\n at o$ (file:///Users/jrbaron/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:38033)","timestamp":"2025-07-01T23:02:00.631Z"}]
30 Comments
Can you provide more details about when you encountered this crash? Was it during the agent loop, or in response to a certain slash command? Do you know when the crash started happening? Is it reproducible?
A number of other users have encountered this issue as well.
Thanks for your response @dicksontsai, it happened a couple of times after using a write or edit tool. For more context, it was editing a sh file that was already hooked to a Post write/edit hook. It stopped happening on .40 or perhaps it was related to the hook not being setup correctly (Claude was debugging it)
I'm also seeing this on darwin (MacOs 14.6.1) and tmux.
NB removing the post write/edit hook I had setup has fixed the issue for me for now. Here's the hook definition I had been using in case that helps:
"PostToolUse": [
{
"matcher": "Edit|MultiEdit|Write",
"hooks": [
{
"type": "command",
"command": "bun run format && bun run lint && bun test"
}
]
}
]
Same for me (MacOS 15.5), claude code 1.0.40 starting to happen after I added hooks for PostToolUse with a bash script.
I am also getting this:
It seems to have started with the introduction of a post edit hook:
Same for me (MacOS 15.5), claude code 1.0.40:
This issue should be fixed in v1.0.41 now. Please upgrade and report back if you see any issues.
@dicksontsai thank you for looking into this. Unfortunately I am still hitting this error
claude -v 1.0.41 (Claude Code)Also experiencing this issue on v1.0.41.
Environment:
Error Details:
Same EPIPE error signature:
Hook Configuration:
Using both PreToolUse and PostToolUse hooks:
npx tsc --noEmitandyarn lint:fix(runs on Write/Edit/MultiEdit)Reproduction:
Error occurs consistently when the PostToolUse hook runs after file edits. The issue disappears completely when commenting out the hooks configuration in
.claude/settings.json.Additional Context:
The PostToolUse hook script includes SIGPIPE handling (
trap 'echo "{\"decision\": \"approve\"}" 2>/dev/null; exit 0' SIGPIPE) but the error still occurs, suggesting the issue is in Claude Code's hook execution pipeline rather than the hook scripts themselves.I am having trouble reproducing the issue, though it still seems to be happening consistently for some reason. If you are willing to report your session with
/bug, that will help me out. Thanks!Bug Description
throw er; // Unhandled 'error' event
Environment Info
Errors
Ok, I was able to get a repro and can confirm that the fix in v1.0.41 was insufficient.
@dicksontsai not sure if this is helpful but it appears that it does not crash with the same scenario but under a Linux VM. Could this be platform (Mac) specific?
There could be platform differences in how stdin flushing is handled. The EPIPE error comes from Claude Code trying to flush the hook input to stdin even after the child process itself has finished. The code did not handle this error properly. This will be fixed in the next release.
## Additional confirmation of the issue
I'm experiencing the same EPIPE error after updating to the latest
ClaudeCode version.
Environment:
Error:
Same error as reported above - crashes during operation with work in
progress lost.
Temporary fix applied:
Following the suggestion in this thread, I've disabled PostToolUse hooks
in
~/.claude/settings.jsonand will test if this resolves the issue.Status: Testing the workaround, will update if the issue persists.
Thank you for the quick fix in v1.0.41!
I reencountered the issue when I asked Claude to move some project hooks to the Claude user folder.
Issue Summary ClaudeCode Version: 1.0.41
Claude Code crashes when hook files are deleted before removing their references from settings.json
Steps to Reproduce
Expected Behavior
Claude Code should handle missing hook files gracefully with an error message rather than crashing
@pauloportella The fix for EPIPE is coming out in the next release, so it's possible that you're encountering the same issue unrelated to the missing references. For reference, here is what the output looks like if a hook file is missing. The error should be non-blocking.
The new release v1.0.43 is now out.
It seems like that the update made hook system crazy.
Something about config.json went wrong and eats usage quickly.
@dhrgusdlrns You can review
claude --debugand/or transcript mode (ctrl-r) to see which hooks are triggering. The only hooks change between 1.0.41 and 1.0.43 was this fix.FWIW 1.0.43 works great for me now.
I watched it with debug mode. I'm not sure about what is really happening, but it seems like even I don't have any hook, but CC repeatedly tries to use hook and watch and edit config.json file whenever CC uses any tool. I didn't feel something was wrong before the update with debug mode, but now it shows too many debug log whenever I do something. I'm sure that I don't feel this weird feeling since I've used CC.
If you need a detailed log or something, please tell me, I'll show you.
I guess it happened after the update, or I removed the json settings with exit option 2
Why don't you file a new issue with your log and your configuration setup? What you're seeing is unrelated to this issue.
Oh, I reviewd. my session by reading jsonl and I found something not related with hooks infused 50000 token.
Yes, you were right, it seems doesn't related with this issue, sorry.
Hi 👋
I am getting the same but could not fix:
Node.js v23.6.0
1.0.55 (Claude Code)
I was experiencing the same EPIPE error with v1.0.55, but downgrading to v1.0.52 resolved the issue for me:
Environment:
macOS
Node.js v20.19.4 (also tested with v22.17.1)
Using global installation
The error completely disappeared after downgrading. Hope this helps others!
Same issue with yesterdays upddate. Has made claude unsuable as it crashes every few minutes.
The cause of the latest crashes is different. We are tracking it in #3891
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.