TooTallNate / keypress

Make any Node ReadableStream emit "keypress" events
358 stars 60 forks source link

piped streams are truncated when keypress is loaded #13

Open rodw opened 9 years ago

rodw commented 9 years ago

Over at request/request I documented an issue that is looking increasingly like a problem in keypress rather than the request module.

In a nutshell:

Given this program:

require("keypress")(process.stdin);
var request = require('request');
request.get("https://github.com/request/request/issues/511").pipe(process.stdout);

The command:

node foo.js

prints the entire document, but the command

node foo.js | cat

is truncated after 1024 characters with this error:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: write EPIPE
    at errnoException (net.js:904:11)
    at Object.afterWrite (net.js:720:19)

Taking out the first line (the call to keypress) makes the issue go away.

I assume that this is probably true for most streams - the use of request here is probably not required to recreate the issue.