From 8f428f3b0deaaf74987076aafa47f36768a05d99 Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 10 Dec 2012 15:58:23 -0800 Subject: [PATCH] streams2: Call read(0) on resume() Otherwise (especially with stdin) you sometimes end up in cases where the high water mark is zero, and the current buffer is at 0, and it doesn't need a readable event, so it never calls _read(). --- lib/_debugger.js | 2 +- lib/_stream_readable.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index 19c26aa943..239220962d 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -36,7 +36,7 @@ exports.start = function(argv, stdin, stdout) { } // Setup input/output streams - stdin = stdin || process.openStdin(); + stdin = stdin || process.stdin; stdout = stdout || process.stdout; var args = ['--debug-brk'].concat(argv), diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index f7790c6625..3a65b53fe0 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -521,6 +521,7 @@ Readable.prototype.addListener = Readable.prototype.on; // If the user uses them, then switch into old mode. Readable.prototype.resume = function() { emitDataEvents(this); + this.read(0); }; Readable.prototype.pause = function() { @@ -566,6 +567,8 @@ function emitDataEvents(stream, startPaused) { process.nextTick(function() { stream.emit('readable'); }); + else + this.read(0); }; // now make it start, just in case it hadn't already.