streams2: Call read(0) on resume()
authorisaacs <i@izs.me>
Mon, 10 Dec 2012 23:58:23 +0000 (15:58 -0800)
committerisaacs <i@izs.me>
Fri, 14 Dec 2012 18:52:28 +0000 (10:52 -0800)
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
lib/_stream_readable.js

index 19c26aa..2392209 100644 (file)
@@ -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),
index f7790c6..3a65b53 100644 (file)
@@ -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.