- A brief description
node.js running under WSL doesn't appear to capture stdout or stderr from a spawned Windows process. My test uses a small app that just prints to stdout and stderr. Running it under three configurations gives three results:
- spawning Linux app: stdout and stderr are captured in the node.js program (correct behavior)
- spawning Windows app from WSL file path: WSL error message about CWD is captured in stderr, no stdout is captured.
- spawning Windows app from Windows file path: no stderr, no stdout captured
-
Expected results
node.js should capture the stdout and stderr from the child process
-
Actual results (with terminal output if applicable)
no stdout and no stderr is captured
-
Your Windows build number
16167.rs_lkg, Ubuntu 16.04.2 LTS
-
Steps / All commands required to reproduce the error from a brand new installation
- Create apps that output to stdout and stderr on both Windows path (in my code, c:\tmp) and WSL path (in my code, ~/tmp). I've called the apps hellostd.exe and hellostd.
#include <stdio.h>
int main() {
fprintf(stderr, "hello stderr\n");
fflush(stderr);
fprintf(stdout, "hello stdout\n");
fflush(stdout);
return 0;
}
node.js exectest.js. You have to uncomment each test--I'm not good enough at JavaScript to make this test handle all the cases. The output gets interleaved if they all run in one invocation.
const spawn = require('child_process').spawn;
// Running Linux app properly captures stderr & stdout
//const test = spawn('./hellostd');
// Running Windows app fills stderr with "Unable to translate CWD" error
//const test = spawn('/mnt/c/tmp/hellostd.exe');
// Changing directory into "Windows" leaves empty stderr & stdout
const test = spawn('/mnt/c/tmp/hellostd.exe', {
cwd: "/mnt/c/tmp"
});
test.stdout.on('data', (data) => {
console.log(`process stdout is: ${data}`);
});
test.stderr.on('data', (data) => {
console.log(`process stderr is: ${data}`);
});
test.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
This may be related to closed issue #1774 dealing with race conditions in node.js code running under WSL.
I'm internal to Microsoft, working on the MSVC team. Feel free to contact me directly.
node.js running under WSL doesn't appear to capture stdout or stderr from a spawned Windows process. My test uses a small app that just prints to stdout and stderr. Running it under three configurations gives three results:
Expected results
node.js should capture the stdout and stderr from the child process
Actual results (with terminal output if applicable)
no stdout and no stderr is captured
Your Windows build number
16167.rs_lkg, Ubuntu 16.04.2 LTS
Steps / All commands required to reproduce the error from a brand new installation
node.js exectest.js. You have to uncomment each test--I'm not good enough at JavaScript to make this test handle all the cases. The output gets interleaved if they all run in one invocation.
Strace of the failing command
https://gist.github.com/AndrewPardoe/d57c9dda3b77fccedbe2afbdf9e55ace
Required packages and commands to install
node.js
This may be related to closed issue #1774 dealing with race conditions in node.js code running under WSL.
I'm internal to Microsoft, working on the MSVC team. Feel free to contact me directly.