Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ Readable.prototype.pause = function() {
if (false !== this._readableState.flowing) {
debug('pause');
this._readableState.flowing = false;
this.emit('pause');
// Emit 'pause' on next tick as we do for 'resume'
process.nextTick(() => this.emit('pause'));
}
return this;
};
Expand Down
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