Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Unsupported fd type: TTY #32

Closed
yukunyi opened this issue Mar 22, 2013 · 15 comments
Closed

TypeError: Unsupported fd type: TTY #32

yukunyi opened this issue Mar 22, 2013 · 15 comments

Comments

@yukunyi
Copy link

yukunyi commented Mar 22, 2013

tip:

net.js:50
throw new TypeError('Unsupported fd type: ' + type);
^
TypeError: Unsupported fd type: TTY

in pty.js:66:17

My System ArchLinux x86_64
nodejs version 0.10.1 or 0.10.0
@chjj
Copy link
Owner

chjj commented Mar 22, 2013

This is really tough. Something really lowlevel must have been changed. I can't even implement my own Socket by using raw fs.read()s and fs.write()s. @TooTallNate, any idea what was changed here?

From what I can see:

$ git blame -L 50 lib/net.js
ca5022b8 lib/net.js    (Ben Noordhuis      2013-03-14 15:13:58 +0100   50)   throw new TypeError('Unsupported fd type: ' + type);
$ git show ca5022b8

nodejs/node-v0.x-archive@ca5022b

Not really what I expected.

@TooTallNate
Copy link
Collaborator

We might need to look into using the tty.ReadStream and tty.WriteStream
classes...

On Friday, March 22, 2013, Christopher Jeffrey wrote:

This is really tough. Something really lowlevel must have been changed. I
can't even implement my own Socket by using raw fs.read()s and fs.write()s.
@TooTallNate https://github.com/TooTallNate, any idea what was changed
here?

From what I can see:

$ git blame -L 50 lib/net.js
ca5022b8 lib/net.js (Ben Noordhuis 2013-03-14 15:13:58 +0100 50) throw new TypeError('Unsupported fd type: ' + type);
$ git show ca5022b8

Not really what I expected.


Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-15292377
.

@chjj
Copy link
Owner

chjj commented Mar 22, 2013

After some testing, it appears pty.fork() is hanging for a while in node v0.10.x. Not sure what's going on.

@TooTallNate
Copy link
Collaborator

@chjj I'm playing around with the tty classes right now, seems promising. I'll try to have a refactor ASAP.

@TooTallNate
Copy link
Collaborator

So it looks like a patch as simple as this fixes things:

diff --git a/lib/pty.js b/lib/pty.js
index 046a05b..ed3380c 100644
--- a/lib/pty.js
+++ b/lib/pty.js
@@ -5,6 +5,7 @@
  */

 var net = require('net');
+var tty = require('tty');
 var pty = require('../build/Release/pty.node');

 /**
@@ -63,7 +64,7 @@ function Terminal(file, args, opt) {
     ? pty.fork(file, args, env, cwd, cols, rows, opt.uid, opt.gid)
     : pty.fork(file, args, env, cwd, cols, rows);

-  this.socket = new net.Socket(term.fd);
+  this.socket = new tty.ReadStream(term.fd);
   this.socket.setEncoding('utf8');
   this.socket.resume();

However, I don't totally feel like that's the correct fix. I'm beginning work on a more general purpose refactor in the node-v0.10-compat branch.

@chjj
Copy link
Owner

chjj commented Mar 22, 2013

Doesn't fix anything for me. I've tried several different ways of reading from that fd. I must be doing something wrong. pty.fork hangs then no data is ever read on node v0.10.1.

@dylanvee
Copy link

@TooTallNate's quick-fix patch did work for me.

@TooTallNate
Copy link
Collaborator

@chjj fork() doesn't seem to be hanging for me. It takes the same amount of time as always. Did you recompile the module?

@chjj
Copy link
Owner

chjj commented Mar 23, 2013

Several times. It builds successfully. I'm not sure what else to try other than to get my hands dirty with some debugging. I'll think I'll do an strace or something.

@chjj
Copy link
Owner

chjj commented Mar 23, 2013

Nevermind. I'm a certified idiot today. Problem was completely on my end and the code only made it appear as though pty.fork was hanging. The fix works great.

@yukunyi
Copy link
Author

yukunyi commented Mar 25, 2013

TooTallNate's patch worked fine for me on ArchLinux .

@TooTallNate
Copy link
Collaborator

Wha?

On Sunday, March 24, 2013, yukunyi wrote:

@TooTallNate https://github.com/TooTallNate This patch on my work here.


Reply to this email directly or view it on GitHubhttps://github.com//issues/32#issuecomment-15373792
.

@mwdhouse
Copy link

TooTallNate's patch worked fine for me on Mac OS X 10.8.3.

@TooTallNate
Copy link
Collaborator

I did a quick fix for this and tagged v0.2.2. @chjj You need to do an npm publish since I don't have publish rights on the npm package.

@rufusgor
Copy link

work on ubuntu 10.04 with node v0.10.1

Dan-Lightsource added a commit to Dan-Lightsource/pty.js that referenced this issue Jul 1, 2014
Applying the fix described in issue chjj#32 for a similar issue, which
replaces "new net.Socket()" with "new tty.ReadStream()"

Signed-off-by: Dan O'Donovan <dan@emutex.com>
detunized added a commit to detunized/node-msgpack that referenced this issue Jul 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants