iisnode: Unknown stdin file type

2019-08-03 23:38发布

问题:

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?

回答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;


回答2:

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