Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

When running node on windows with php's proc_open() it crashes with Unknown system errno 10106 #1943

Closed
Shyru opened this issue Oct 26, 2011 · 8 comments

Comments

@Shyru
Copy link

Shyru commented Oct 26, 2011

We have a small wrapper script (written in php) that starts node with a given javascript file.
To read and write to nodes stdin/stdout we use proc_open() of php. When doing this, node crashes with this exception:

node.
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: listen Unknown system errno 10106
    at errnoException (net.)
    at Array.<anonymous> (net.)
    at EventEmitter._tickCallback (node.)

Our node server uses faye () to listen on port 8000 for incoming requests.
Fore reference this is the script we are trying to execute:

console.log("startup");
var http = require('http'),
    faye = require('faye');


var bayeux = new faye.NodeAdapter({mount: '/faye', timeout: 45});

bayeux.listen(8000);
console.log("running");

Note: I dont get the output 'startup' or 'running' from inside php.

Important: When running node from commandline with this script, everything works perfectly! Its just that starting it from php with proc_open() makes it go crazy!
Any idea what could be the cause of this?

Edit: I forgot to say this is using current node 0.5.10, but the error existed already in previous node versions, but the crashes where all different, but it never worked. :-)

@bnoordhuis
Copy link
Member

Closing this for now, we don't support third-party modules. Can you strace or dtrace it? If this is a bug in Node itself, I'll be happy to fix it.

@Shyru
Copy link
Author

Shyru commented Oct 26, 2011

Unfortunatly this has nothing to do with faye.
Running this minimal example causes the same error.

var http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

How can I provide more debug information on windows?

@bnoordhuis bnoordhuis reopened this Oct 26, 2011
@bnoordhuis
Copy link
Member

Reopening. @igorzi and @piscisaureus, can you look into this?

@igorzi
Copy link

igorzi commented Oct 26, 2011

@Shyru most likely this is due PHP's proc_open() not setting node's systemroot and systemdrive env variables (which are needed to initialize winsock). See this commit in libuv: joyent/libuv@3409c9b. We make sure to set those variables for spawn to fix this issue.

@ry
Copy link

ry commented Oct 26, 2011

Do this in the C++ code:
https://github.com/joyent/node/blob/c83dda89a4bc12925e2dd83db9ef978fe4efae12/src/process_wrap.cc#L117-128
or in JS code just before the spawn:
https://github.com/joyent/node/blob/c83dda89a4bc12925e2dd83db9ef978fe4efae12/lib/child_process.js#L402

We should have a windows specific test which spawns a child and checks that systemroot and systemdrive are set

@Shyru
Copy link
Author

Shyru commented Oct 27, 2011

I can confirm that setting up the environment correctly solves the problem. In my particular case php's option variables_order was not set to initialize $_ENV. So I passed an empty array of env variables to proc_open. After fixing this it works like intended.
Neverthelesse it would be great if node would work under windows if these are not set, as you suggested.

@stollr
Copy link

stollr commented May 10, 2013

@igorzi and @ry
is it possible to throw an error to STDERR if the SystemRoot or SystemDrive env variable has not been set? Otherwise it is really hard to find the reason why node exits. I had the same problem like @Shyru and needed several hours to locate the problem :-(

@jasnell
Copy link
Member

jasnell commented May 15, 2015

Closing this for now as there does not appear to be anything to do at this point. Can reopen later if new information is received.

@jasnell jasnell closed this as completed May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants