summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2021-11-24 09:42:24 +0100
committerMichaël Zasso <targos@protonmail.com>2021-11-29 10:47:35 +0100
commit86d1c0b19d91c9ba6e2869eb7c5dee8262fb8d80 (patch)
treeb53a17fce7b4f23ea8849dde1dfee6e74c7d53ed
parent3bfc9f5b4755ba1d2262f47c7cef60c0eaf6e384 (diff)
downloadnode-new-86d1c0b19d91c9ba6e2869eb7c5dee8262fb8d80.tar.gz
stream: drain Transform with 0 highWaterMark
Fixes: https://github.com/nodejs/node/issues/40935 PR-URL: https://github.com/nodejs/node/pull/40947 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
-rw-r--r--lib/internal/streams/transform.js1
-rw-r--r--test/parallel/test-stream-passthrough-drain.js8
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/internal/streams/transform.js b/lib/internal/streams/transform.js
index 26e0b07c29..cbd23185fa 100644
--- a/lib/internal/streams/transform.js
+++ b/lib/internal/streams/transform.js
@@ -196,6 +196,7 @@ Transform.prototype._write = function(chunk, encoding, callback) {
wState.ended || // Backwards compat.
length === rState.length || // Backwards compat.
rState.length < rState.highWaterMark ||
+ rState.highWaterMark === 0 ||
rState.length === 0
) {
callback();
diff --git a/test/parallel/test-stream-passthrough-drain.js b/test/parallel/test-stream-passthrough-drain.js
new file mode 100644
index 0000000000..f5c98947e2
--- /dev/null
+++ b/test/parallel/test-stream-passthrough-drain.js
@@ -0,0 +1,8 @@
+'use strict';
+const common = require('../common');
+const { PassThrough } = require('stream');
+
+const pt = new PassThrough({ highWaterMark: 0 });
+pt.on('drain', common.mustCall());
+pt.write('hello');
+pt.read();