Node.js: Error: write EPIPE (broken pipe on stdout)
Error: write EPIPE
at WriteWrap.afterWrite [as oncomplete] (net.js:1271:14)
at Socket._writeGeneric (net.js:933:5)
Immediate Remediation
bash
echo "process.stdout.on('error', (err) => { if (err.code === 'EPIPE') process.exit(0); });" >> app.jsRoot Cause Analysis
The process attempted to write to a socket or stream that has been closed by the remote end, typically because the client disconnected or the downstream process in a pipeline exited early.
Verification & Guardrails
- Ensure you handle the 'error' event on the specific stream, not just globally.
- This fix ignores EPIPE errors; verify that other errors are still thrown.
- Test with Node.js v14+ as stream error handling may vary.
Have a custom or uncategorized crash?
Run your trace through our in-memory client privacy sandbox for instant SRE remediation.