Skip to content

Commit

Permalink
tty: don't read from console stream upon creation
Browse files Browse the repository at this point in the history
The tty.ReadStream constructor initializes this as a socket,
which causes a read to be initiated. Even though during stdin
initalization we call readStop shortly after, the read operation
can consume keypress events from the system buffers.

Fixes: nodejs#5384

PR-URL: nodejs#5776
Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
  • Loading branch information
orangemocha committed Mar 23, 2016
1 parent f429fe1 commit 4611389
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@ function ReadStream(fd, options) {
if (!(this instanceof ReadStream))
return new ReadStream(fd, options);

// pauseOnCreate to avoid reading from the sytem buffer
options = util._extend({
highWaterMark: 0,
readable: true,
writable: false,
handle: new TTY(fd, true)
handle: new TTY(fd, true),
pauseOnCreate: true
}, options);

net.Socket.call(this, options);

this.isRaw = false;
this.isTTY = true;

// Let the stream resume automatically when 'data' event handlers
// are added, even though it was paused on creation
this._readableState.flowing = null;
}
inherits(ReadStream, net.Socket);

Expand Down

0 comments on commit 4611389

Please sign in to comment.