unhandled ECONNRESET when using head #18

Open
pigulla opened this Issue Jun 30, 2013 · 0 comments

1 participant

@pigulla

I'm trying to use head to only get the first n bytes of output. See the following (contrived) example:

var procstream = require('procstreams');

procstream('cat', ['/dev/random'])
    .pipe('head', ['--bytes=100'])
    .data(function (err, stdout, stderr) {
        console.log(stdout.length + ' bytes read');
    });

When that code is run, I get an unhandled error event:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: read ECONNRESET
    at errnoException (net.js:901:11)
    at Pipe.onread (net.js:556:19)

I'm not much of a Linux shell guy but I assume head just closes the stream when enough data was read. It would be nice if procstream could handle these kinds of situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment