New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

epipebomb

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

epipebomb

Destroy EPIPE errors when stdout runs through a truncated pipe

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by92.21%
Maintainers
1
Weekly downloads
 
Created
Source

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
;(function log() {
  console.log('tick')
  process.nextTick(log)
})()
Oh the humanity
$ node example.js | head
tick
tick
tick
tick
tick
tick
tick
tick
tick
tick

events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: write EPIPE
    at errnoException (net.js:782:11)
    at Object.afterWrite (net.js:600:19)

After

example.js
require('epipebomb')()

;(function log() {
  console.log('tick')
  process.nextTick(log)
})()
Oh the joy!
$ node example.js | head
tick
tick
tick
tick
tick
tick
tick
tick
tick
tick

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.

FAQs

Package last updated on 12 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc