Skip to content

Instantly share code, notes, and snippets.

@Raynos
Last active December 11, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/180ed4fa7ba12a521ec4 to your computer and use it in GitHub Desktop.
Save Raynos/180ed4fa7ba12a521ec4 to your computer and use it in GitHub Desktop.
@@ -367,8 +371,10 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
// specific writer, then it would cause it to never start
// flowing again.
// So, if this is awaiting a drain, then we just call it now.
- // If we don't know, then assume that we are waiting for one.
- if (!dest._writableState || dest._writableState.needDrain)
+ // If we don't know, then assume that we are not
+ // waiting for one. If we don't know it's the writer's
+ // responsibility to manage drain state.
+ if (dest._writableState && dest._writableState.needDrain)
ondrain();
}
@@ -496,6 +502,7 @@ Readable.prototype.unpipe = function(dest) {
state.pipes = null;
state.pipesCount = 0;
this.removeListener('readable', pipeOnReadable);
+ state.flowing = false;
if (dest)
dest.emit('unpipe', this);
return this;
@@ -510,6 +517,7 @@ Readable.prototype.unpipe = function(dest) {
state.pipes = null;
state.pipesCount = 0;
this.removeListener('readable', pipeOnReadable);
+ state.flowing = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment