Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

streams2: pause() should be immediate

  • Loading branch information...
commit 2615d7377c52f704754114fe997edc00400a1c2d 1 parent 757e26b
@isaacs isaacs authored
View
8 lib/_stream_readable.js
@@ -521,15 +521,13 @@ Readable.prototype.addListener = Readable.prototype.on;
// If the user uses them, then switch into old mode.
Readable.prototype.resume = function() {
emitDataEvents(this);
- return this.resume();
};
Readable.prototype.pause = function() {
- emitDataEvents(this);
- return this.pause();
+ emitDataEvents(this, true);
};
-function emitDataEvents(stream) {
+function emitDataEvents(stream, startPaused) {
var state = stream._readableState;
if (state.flowing) {
@@ -537,7 +535,7 @@ function emitDataEvents(stream) {
throw new Error('Cannot switch to old mode now.');
}
- var paused = false;
+ var paused = startPaused || false;
var readable = false;
// convert to an old-style stream.
View
6 test/simple/test-fs-empty-readStream.js
@@ -32,12 +32,13 @@ fs.open(emptyFile, 'r', function (error, fd) {
var read = fs.createReadStream(emptyFile, { 'fd': fd });
read.once('data', function () {
- throw new Error("data event should not emit");
+ throw new Error('data event should not emit');
});
var readEmit = false;
read.once('end', function () {
readEmit = true;
+ console.error('end event 1');
});
setTimeout(function () {
@@ -52,12 +53,13 @@ fs.open(emptyFile, 'r', function (error, fd) {
read.pause();
read.once('data', function () {
- throw new Error("data event should not emit");
+ throw new Error('data event should not emit');
});
var readEmit = false;
read.once('end', function () {
readEmit = true;
+ console.error('end event 2');
});
setTimeout(function () {
Please sign in to comment.
Something went wrong with that request. Please try again.