summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-10-03 20:53:58 +0200
committerRich Trott <rtrott@gmail.com>2019-10-05 17:43:21 -0700
commitf58e8eb103ff30876198946a4a9c1280b987c1fb (patch)
tree07c7004c14d808a3a130a3c79745eb3244efb4ef /test
parent0b495a899bdf9a26b25a6e31177512531c841e0e (diff)
downloadandroid-node-v8-f58e8eb103ff30876198946a4a9c1280b987c1fb.tar.gz
android-node-v8-f58e8eb103ff30876198946a4a9c1280b987c1fb.tar.bz2
android-node-v8-f58e8eb103ff30876198946a4a9c1280b987c1fb.zip
stream: do not deadlock duplexpair
If nothing is buffered then _read will not be called and the callback will not be invoked, effectivly deadlocking. Fixes: https://github.com/nodejs/node/issues/29758 PR-URL: https://github.com/nodejs/node/pull/29836 Refs: https://github.com/nodejs/node/pull/29649 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Diffstat (limited to 'test')
-rw-r--r--test/common/duplexpair.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/common/duplexpair.js b/test/common/duplexpair.js
index 0783aeb861..4eb4f326f2 100644
--- a/test/common/duplexpair.js
+++ b/test/common/duplexpair.js
@@ -24,8 +24,12 @@ class DuplexSocket extends Duplex {
_write(chunk, encoding, callback) {
assert.notStrictEqual(this[kOtherSide], null);
assert.strictEqual(this[kOtherSide][kCallback], null);
- this[kOtherSide][kCallback] = callback;
- this[kOtherSide].push(chunk);
+ if (chunk.length === 0) {
+ process.nextTick(callback);
+ } else {
+ this[kOtherSide].push(chunk);
+ this[kOtherSide][kCallback] = callback;
+ }
}
_final(callback) {