EPIPE Bomb
By default, node throws EPIPE
errors if process.stdout
is being written to and
a user runs it through a pipe that gets closed while the process is still outputting
(eg, the simple case of piping a node app through head
).
This seemed a little overzealous to me, so I wrote this to suppress such errors.
Before
example.js
; { console process}
Oh the humanity
$ node example.js | headticktickticktickticktickticktickticktick events.js:66 throw arguments[1]; // Unhandled 'error' event ^Error: write EPIPE at errnoException at Object.afterWrite
After
example.js
; { console process}
Oh the joy!
$ node example.js | headticktickticktickticktickticktickticktick
CLI usage (Node 4.x and up)
Require epipebomb/register
from the command line
node -r epipebomb/register some-script.js | head
or use epipebomb
as a drop-in replacement for node
epipebomb some-script.js | head
Notes
Only the EPIPE
error is captured on process.stdout
- all other errors are thrown as per usual.