Nodeclipse / nodeclipse

Nodeclipse-1 : Eclipse plugin for Node.js, PhantomJS development (Nodeclipse core plugin); Maven and Gradle (with Android) plugins
https://nodeclipse.github.io/
158 stars 76 forks source link

Node.js app with cluster does not execute inside Nodeclipse // Unknown system errno 203 #81

Closed paulvi closed 10 years ago

paulvi commented 11 years ago

This code with cluster usage does not execute inside Nodeclipse

    var cluster = require('cluster');
    var numCPUs = require('os').cpus().length;

    if (cluster.isMaster) {
        // Fork workers.
        for ( var i = 0; i < numCPUs; i++) {
            cluster.fork();
        }

        cluster.on('death', function(worker) {
            console.log('worker ' + worker.pid + ' died');
            cluster.fork();
        });
    }

It is finishing with

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn Unknown system errno 203
    at errnoException (child_process.js:945:11)
    at Process.ChildProcess._handle.onexit (child_process.js:736:34)

Possibly output is less, because of #71

zamnuts commented 11 years ago

@PaulVI I was able to reproduce this. It affects nodeclipse version 0.5.0.201309080643 and latest 0.6; reverting to 0.4.0.201305191444 resolves the issue (temp fix). However, I am getting a more detailed error message (not sure if it is related, exactly):

Error: write EPIPE - cannot write to IPC channel.

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: write EPIPE - cannot write to IPC channel.
    at errnoException (child_process.js:980:11)
    at ChildProcess.target.send (child_process.js:455:16)
    at ****.startNodes (****.js:58:10)
    at new **** (****.js:30:7)
    at Object.<anonymous> (****.js:117:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

Version Information:

I used the following updates to switch between versions (clean uninstalls and restarts of workspace each time, of course):

...In other news, it would be nice to keep the version history intact on the primary update site(s) so you can revert to a previous eclipse configuration (under "Installation History"). When using the current update sites for 0.5 and 0.6, Eclipse says it cannot find the old plugin versions.

paulvi commented 11 years ago

Do you mean that the same Node.js code produces different errors in Eclipse?

by the way http://dl.bintray.com/nodeclipse/nodeclipse is actually mirror of 0.5
the latest 0.6 is at http://dl.bintray.com/nodeclipse/nodeclipse/0.6.0/ (that is switch to Bintray after it proved to be better then GitHub pages)

The latest 0.7

$ git clone git://github.com/Nodeclipse/nodeclipse-1.git

Then build with

$ mvn package

paulvi commented 11 years ago

@zamnuts There is no need to install/unistall plugins. Just get second(third..) Eclipse . (And open the same project in different Eclipses. And since 0.6 even debug in the same time by setting different debug ports)

For example Enide Studio http://sourceforge.net/projects/nodeclipse/files/Enide-Studio/ It will be faster comparing to Eclipse 4.2.2

Then you can set once more Eclipse and update Nodeclipse. there is very convinient Nodeclipse plugin list under Help menu.

zamnuts commented 11 years ago

@PaulVI Using your original Cluster source I get the same results you do:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn Unknown system errno 203
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)

That is with a new project and nodeclipse 0.6.

The error I received was also relevant to ChildProcess and occurred during provisioning of those child processes. The difference is that Error: spawn Unknown system errno 203 is presented when using Cluster while Error: write EPIPE - cannot write to IPC channel. is presented when using ChildProcess directly.

To reproduce (using the sample code from http://nodejs.org/api/child_process.html#child_process_child_send_message_sendhandle), first use main.js

var cp = require('child_process');

var n = cp.fork(__dirname + '/sub.js');

n.on('message', function(m) {
  console.log('PARENT got message:', m);
});

n.send({ hello: 'world' });

...and sub.js:

process.on('message', function(m) {
  console.log('CHILD got message:', m);
});

process.send({ foo: 'bar' });

Works in 0.4, but produces in 0.6:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: write EPIPE - cannot write to IPC channel.
    at errnoException (child_process.js:980:11)
    at ChildProcess.target.send (child_process.js:455:16)
    at Object.<anonymous> (C:\dev\workspaces\test\fork-test\main.js:9:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

I'm not saying it is the same error, but it is a pretty close coincidence, don't you think? If you feel these are unrelated, I can open a separate bug report.

btw, i ended up just duplicating my eclipse directory and installed the other version (for now), thanks for the tip

paulvi commented 10 years ago

I wonder if using V8 debugger coming with 0.4 version e.g. taking Nodeclipse NTS http://sourceforge.net/projects/nodeclipse/files/ but with Nodeclipse itself being the latest could work.

ihgreenman commented 10 years ago

I'm seeing this issue (in a different context) as well.

Exercising a little Google-fu, I came up with errno 203 is "Environment variable missing"

Looking at process.env, it only has one item, "SystemRoot". No PATH, no nothing else.

ihgreenman commented 10 years ago

It looks like in the "Edit launch configuration properties" window that the "Append to environment" is not working properly; it appears that no matter what that the native environment variables are getting nuked.

copied to #122

ihgreenman commented 10 years ago

OK, workaround on my system. YMMV; you may need more than these.

Open cmd.exe and run "set" to get the environment variables for your system.

Take note of the values for "PATH", "TEMP", "TMP", and "SystemDrive".

Open the properties for the nodeclipse project. Click on Run/Debug Settings, then edit the launch configuration that is failing. Click on "Environment". Add the four environment variables above.

paulvi commented 10 years ago

Do I understand right that the cause errno 203 is "Environment variable missing" and it should be fixed when "PATH", "TEMP", "TMP", and "SystemDrive" are passed?

paulvi commented 10 years ago

With commit above the example code can run inside Eclipse at least on Windows

var cluster = require('cluster');
var numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
    // Fork workers.
    for ( var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }

    cluster.on('death', function(worker) {
        console.log('worker ' + worker.pid + ' died');
        cluster.fork();
    });
} else {
    console.log('worker');
}
paulvi commented 10 years ago

@zamnuts example also works (on Windows)

ihgreenman commented 10 years ago

@PaulVI, you are correct: The issue being reported by errno 203 is that a required environment variable is missing. For my environment, I needed to set those four variables.

paulvi commented 10 years ago

OK, so this #81 is not actually bug, because code will run once those environment variables are set. So we are working on enhancement to pass those environment variables correctly under major OSes.

Also @ihgreenman Ian, I copied ""Append to environment" is not working properly" into #122. Do you have code snippet to test this. Please continue in #122 .

centaurus45 commented 10 years ago

The fix of setting the environment variables within the run configuration worked for me; I can run the application through Nodeclipse. However, when running the application in debug mode (also with the environment variables set), the node js application will hang after creating the cluster workers. No errors are thrown. If I remove the cluster code, the application will run in debug mode just fine.

Update, below is how I got around the problem described above

https://github.com/department-of-veterans-affairs/vlerdas-ecrud/pull/71

Stelminator commented 8 years ago

@palcocer I found this while trying to debug a nodejs cluster app, but your link is dead. Any chance you could explain your workaround here?