-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
"Implement me. Unknown stdin file type!" error thrown when running headless process in win32 #11656
Comments
/cc @nodejs/platform-windows |
Can you provide a minimal test case that reproduces the issue, preferably without using third-party libraries? |
The commit message of angular/angular-cli@4af7a42 sounds like a good clue:
I can’t test that myself, though. |
That doesn't say much. What does "running in a headless process" mean exactly? |
I'm sorry for the lack of detail - I'm kind of blind to the details of the issue. I'm extra new to Node, so I can't really give you an example without a third-party plugin. I am reproducing the issue while running PostCSS using their postcss-cli module via the command line in Windows, like this: "cmd /c cd /d [node directory] postcss [arguments]" Again, apologies for the briefness! I know this is not a lot to go on. I will provide more details if I can as I try to deal with the issue. |
In that case I think it would be more appropriate to post the issue in the PostCSS repo. |
I originally posted it in the repo of the module that actually threw the error (get-stdin): sindresorhus/get-stdin#20 He directed me to post here as NodeJS did not provide code to handle the situation. |
Fwiw, this issue was opened because of sindresorhus/get-stdin#20 (comment) (@jakelauer: Generally, it helps a lot if you could add cross-links when you open issues on multiple repositories!), and it looks to me like this is something that could/should be fixed in Node core. |
@addaleax Thanks for the pointers :) I haven't had a lot of experience opening issues on GitHub either! |
Interesting sidenote: I do not experience this in Windows 10 |
I guess 'headless' here means either a non-console application or a windows service. In either case, node is started from a non-shell parent process with custom (or no) stdin. When node is started normally through shell, the C runtime makes sure that the stdin is created and supplied to the process, this is the responsibility of a parent if node is started through createProcess* calls. The error message indicates that stdin (the fd 0 which node expects stdin to be at the start-up) is invalid, which leads all the suspecion to its creator process. |
Maybe Node should do something like Lines 4137 to 4147 in cccc6d8
|
@addaleax - yes, that makes sense to me - though this will not mitigate (I don't think we should mitigate an invalid descriptor scenario if the parent chose to give us a bad one) the issue, this will make sure that we make the right assertion at the right place. Let me see if I can come up with a test scenario that fails node in the above manner |
For what it's worth, myself and several others are experiencing the same issue with Yarn only on Windows 7. Windows 10 works fine. Specifically, the issue occurs when Yarn is invoked from Visual Studio 2015 or 2017's NPM Task Runner extension. See the Yarn issue logged here. Sure, I could submit a PR to fix Yarn, but it seems like the source of the problem is Node's handling of |
I tested with a parent, and with this sequence: fclose(stdin);
CreateProcess(NULL, argv[1], NULL,NULL,FALSE,0,NULL,NULL,&si,&pi); node fails in a similar manner:
|
@gireeshpunathil Can you provide a full test case? |
@seishun - here it is: #include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
void _tmain(int argc, TCHAR *argv[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
fclose(stdin);
if (!CreateProcess(NULL, // No module name (use command line)
argv[1], // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
)
{
printf("CreateProcess failed (%d).\n", GetLastError());
return;
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
} Needless to say, this need to be added in a "win 32 console application" project in Visual Studio, otherwise some of the headers as well as the linkage needs to be adjusted accordingly. |
Well, I can reproduce the error with the above code. But I doubt this is what PostCSS does, as their code is 100% JavaScript. This is the reason why I suggested to post this issue in the PostCSS repo. If the maintainers of PostCSS think this is a bug in Node.js, then they can post an issue here with a proper explanation. |
ok, sounds good. |
+1, I'm having the exact same issue hosting my node application (which deep down uses The problem can be narrowed down to |
@dcastro If you aren't using any libraries, can you provide steps to reproduce the issue? |
@seishun I'm using iisnode... it's a binary iis module, not a library, but I'm guessing you're looking for a demo with no dependencies whatsoever, right? If so, apologies, I don't have one nor do I know enough about node to come up with one. If a demo with iisnode would do, I'll be happy to provide one. |
@dcastro A demo with no dependencies is ideal, but steps to reproduce with |
I have the same issue in Bash for Windows 10. There is a code example in this issue: |
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: nodejs#875 Fixes: nodejs#11656 PR-URL: nodejs#11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: #875 Fixes: #11656 PR-URL: #11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: #875 Fixes: #11656 PR-URL: #11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: #875 Fixes: #11656 PR-URL: #11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: #875 Fixes: #11656 PR-URL: #11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: #875 Fixes: #11656 PR-URL: #11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Check that stdin, stdout and stderr are valid file descriptors on Windows. If not, reopen them with 'nul' file. Refs: nodejs/node#875 Fixes: nodejs/node#11656 PR-URL: nodejs/node#11863 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Hello! Any progress here?
|
I've got this problem too - see related issue here. Tracking the issue through issues related to this WSL issue it looks like at least five projects ran into this problem and closed their issues with no resolution. It would be really great to know if this is a regression, whether it's node or WSL, and so on? I'd suggest to reopen this issue? |
WSL is essentially a Linux emulator. If it works on Linux but not in WSL, then by definition it's a WSL bug. |
@bnoordhuis At least, what could cause this bug from the node perspective? |
Take a look at |
Wait, I'll link you to it: Lines 292 to 348 in 039cdeb
|
It's really not - it's running a real Ubuntu distro + some kernel/driver patches for interop.
Not by definition, no - there are countless Linux distros, and if you look through the related issues, you'll find at least a few people are reporting the same error under other Linux distros. From what I could gather, the issue could not be narrowed down to WSL-only, and the issue was closed on the WSL issue tracker with the conclusion "This is not a bug in Bash on Windows so I will close this issue". If you think this is incorrect, maybe ask them to reopen the issue? |
It's an emulator in that it emulates the Linux system call interface. If you can reproduce the error with a real Linux kernel, then that's something we can look into to. If it only happens under WSL, it's a WSL bug. |
Hi there - I encountered this while attempting to run PostCSS commands via the PostCSS-CLI command line implementation.
Note - I have only encountered this error in Windows 7. Windows 10 seems to work fine.
The exact error is as shown:
I found a similar issue in Angular here: angular/angular-cli#4870
They solved it like this:
angular/angular-cli@4af7a42
Let me know if you need more information - I am very new to Node so you might need to simplify any questions you have for me.
The text was updated successfully, but these errors were encountered: