summaryrefslogtreecommitdiff
path: root/test/pseudo-tty
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2018-07-03 18:35:59 +0200
committerMatteo Collina <hello@matteocollina.com>2018-08-22 16:41:54 +0200
commit91eec00ca20a54b1dc010cfc2fb34bc2f39eab6b (patch)
tree6dfcf264b13f29079aa97fbb64c7b4e1a61cc783 /test/pseudo-tty
parent6acb55041b53021171019ad755b72515a3712a9e (diff)
downloadandroid-node-v8-91eec00ca20a54b1dc010cfc2fb34bc2f39eab6b.tar.gz
android-node-v8-91eec00ca20a54b1dc010cfc2fb34bc2f39eab6b.tar.bz2
android-node-v8-91eec00ca20a54b1dc010cfc2fb34bc2f39eab6b.zip
tty: make _read throw ERR_TTY_WRITABLE_NOT_READABLE
This change avoid an 'read ENOTCONN' error introduced by libuv 1.20.0 when trying to read from a TTY WriteStream. Instead, we are throwing a more actionable ERR_TTY_WRITABLE_NOT_READABLE. Fixes: https://github.com/nodejs/node/issues/21203 PR-URL: https://github.com/nodejs/node/pull/21654 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/pseudo-tty')
-rw-r--r--test/pseudo-tty/test-tty-write-stream-resume-crash.js17
-rw-r--r--test/pseudo-tty/test-tty-write-stream-resume-crash.out0
2 files changed, 17 insertions, 0 deletions
diff --git a/test/pseudo-tty/test-tty-write-stream-resume-crash.js b/test/pseudo-tty/test-tty-write-stream-resume-crash.js
new file mode 100644
index 0000000000..12ec1df45a
--- /dev/null
+++ b/test/pseudo-tty/test-tty-write-stream-resume-crash.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const common = require('../common');
+const { WriteStream } = require('tty');
+const fd = common.getTTYfd();
+
+// Calling resume on a tty.WriteStream should be a no-op
+// Ref: https://github.com/nodejs/node/issues/21203
+
+const stream = new WriteStream(fd);
+stream.resume();
+
+stream.on('error', common.expectsError({
+ code: 'ERR_TTY_WRITABLE_NOT_READABLE',
+ type: Error,
+ message: 'The Writable side of a TTY is not Readable'
+}));
diff --git a/test/pseudo-tty/test-tty-write-stream-resume-crash.out b/test/pseudo-tty/test-tty-write-stream-resume-crash.out
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/pseudo-tty/test-tty-write-stream-resume-crash.out