summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2020-12-18 12:14:30 +0100
committerRobert Nagy <ronagy@icloud.com>2020-12-20 10:27:35 +0100
commitab895bd587ed47423a6baab0bd6934128aa8990d (patch)
tree0c302183a6fd12b1a71efa17dc9e4a8337773d48 /test
parentdaa132260d19a5a8f46253259101a586dcba6fc4 (diff)
downloadios-node-v8-ab895bd587ed47423a6baab0bd6934128aa8990d.tar.gz
ios-node-v8-ab895bd587ed47423a6baab0bd6934128aa8990d.tar.bz2
ios-node-v8-ab895bd587ed47423a6baab0bd6934128aa8990d.zip
stream: fix pipe deadlock when starting with needDrain
Fixes: https://github.com/nodejs/node/issues/36544 PR-URL: https://github.com/nodejs/node/pull/36563 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-stream-pipe-needDrain.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/parallel/test-stream-pipe-needDrain.js b/test/parallel/test-stream-pipe-needDrain.js
index 7e8f5f6f47..0836c81da2 100644
--- a/test/parallel/test-stream-pipe-needDrain.js
+++ b/test/parallel/test-stream-pipe-needDrain.js
@@ -5,12 +5,13 @@ const assert = require('assert');
const Readable = require('_stream_readable');
const Writable = require('_stream_writable');
-// Pipe should not continue writing if writable needs drain.
+// Pipe should pause temporarily if writable needs drain.
{
const w = new Writable({
write(buf, encoding, callback) {
-
- }
+ process.nextTick(callback);
+ },
+ highWaterMark: 1
});
while (w.write('asd'));
@@ -20,10 +21,12 @@ const Writable = require('_stream_writable');
const r = new Readable({
read() {
this.push('asd');
+ this.push(null);
}
});
- w.write = common.mustNotCall();
+ r.on('pause', common.mustCall(2));
+ r.on('end', common.mustCall());
r.pipe(w);
}