WSL: NodeJS cannot spawn a process that reads from STDIN

  • A brief description Using node.js v4.7.3 it is not possible to spawn a process that reads from stdin. An exception occurs that is only reproducible on Windows. On linux it works as expected.

  • Expected results Should spawn process that can read from stdin

  • Actual results (with terminal output if applicable) An exception occurs

node.js:724
          throw new Error('Implement me. Unknown stdin file type!');
          ^

Error: Implement me. Unknown stdin file type!
    at process.stdin (node.js:724:17)
    at Object.<anonymous> (/mnt/c/Users/reyad.attiyat/Workspace/node-test/readStdin.js:2:8)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:990:3

  • Your Windows build number 15055
  • Steps / All commands required to reproduce the error from a brand new installation Create file spawn.js
const spawn = require('child_process').spawn;

const node = spawn('node', ['./readStdin.js'], {stdio: ['pipe', 'pipe', 'pipe'], shell: true});

node.stdout.on('data', (output) => {
    console.log(output.toString());
});

node.stderr.on('data', (output) => {
    console.log(output.toString());
});

node.stdin.setEncoding('utf8');
node.stdin.write('HELLO WORLD');
node.stdin.end();

Create file readStdin.js


process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', (input) => {
    console.log(input.toString());
});

Run command: node spawn.js

Here is the related node.js issue for the same problem on windows: https://github.com/nodejs/node/issues/11656

I would expect it to behave the same on bash for windows as it does in linux

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 26 (5 by maintainers)

Most upvoted comments

I tracked this down to an issue with getsockaddr for unix sockets. Fix will be coming in an upcoming Insiders build.

Just confirming that my specific case is indeed fixed as of the October update (build 17763).

Let me know if this is still a problem

Seems okay (prints “Hello”) on 18219.

Regardless, this is fixed in recent skip-ahead insider builds.

@benhillis to get this now, I just sign up for Windows 10 Insider Preview and install the Preview build? (anything else or is that it?)