Skip to content

Instantly share code, notes, and snippets.

@HomerSp
Created December 18, 2020 10:29
Show Gist options
  • Save HomerSp/07ec63dacf49aac5f55a62b7c09dc313 to your computer and use it in GitHub Desktop.
Save HomerSp/07ec63dacf49aac5f55a62b7c09dc313 to your computer and use it in GitHub Desktop.
readable.js
diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js
index 93153908fe..366a2a5ad6 100644
--- a/lib/internal/streams/readable.js
+++ b/lib/internal/streams/readable.js
@@ -787,6 +787,11 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
if (dest.writableNeedDrain === true) {
if (state.flowing) {
src.pause();
+
+ // Resume src when we can
+ dest.once('drain', function() {
+ src.resume();
+ });
}
} else if (!state.flowing) {
debug('pipe resume');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment