iisnode: Unknown stdin file type
Asked Answered
L

2

1

I have iisnode working smoothly on win8/IIS8. I created a very simple hello world and it works great. However, when I try to use process.stdin I get the following error:

Application has thrown an uncaught exception and is terminated:
Error: Implement me. Unknown stdin file type!
    at process.startup.processStdio.process.openStdin [as stdin] (node.js:405:17)
    at Object.<anonymous> (C:\ApprendaPlatform\SiteData\developer\v1\root\shim\node_modules\actionhero\bin\zzz.js:7:20)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (C:\Program Files\iisnode\interceptor.js:210:1)
    at Module._compile (module.js:449:26)

Note that I do not get this with process.stdout.

My code:

// kaboom!
var breakthings = process.stdin;

// works
// var breakthings = process.stdout;

Is iisnode doing something funky to stdin, or have I misconfigured something?

Lawrenson answered 24/4, 2014 at 22:34 Comment(1)
Just in case anyone else encounters this: This appears to be a bug in iisnode. The github issue is here: github.com/tjanczuk/iisnode/issues/337 Node uses process.stdin to gather input from the console. Since there's no console in play with iisnode, that object isn't necessary. As a workaround, wrap any block that uses process.stdin with something like so: if(!process.env.IISNODE_VERSION) { // do stuff with process.stdin }Lawrenson
L
1

In my case, and since the issue still occurs, I just override the getter from the process.stdin in the iisnode file

var events = require('events');

// Define a custom getter for process.stdin since iisnode still didn't fix the bug
process.__defineGetter__('stdin', function(){
    return new events.EventEmitter();
})

// no kaboom anymore ;)
var breakthings = process.stdin;

hope this help ;)

UPDATE (02-06-2016): In a more advisable and clean way:

var events = require('events');

delete process.stdin;
process.stdin = new events.EventEmitter();

// no kaboom anymore ;)
var breakthings = process.stdin;
Likable answered 31/5, 2016 at 10:11 Comment(0)
L
0

Actionhero now has a check for this kind of thing https://github.com/evantahler/actionhero/commit/465a85fba9800466ab9ca3d5df65a18f7decd830

Lambency answered 10/5, 2014 at 6:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.