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

Closed
paulvi opened this Issue Oct 10, 2013 · 15 comments

Comments

Projects
None yet
5 participants
@paulvi
Member

paulvi commented Oct 10, 2013

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

This comment has been minimized.

Show comment
Hide comment
@zamnuts

zamnuts Oct 16, 2013

@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:

  • Eclipse Version 4.2.2
  • JDK 1.7.0_13 (64-bit)
  • Node.js 0.10.16 (64-bit)
  • Windows 7 (64-bit)

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.

zamnuts commented Oct 16, 2013

@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:

  • Eclipse Version 4.2.2
  • JDK 1.7.0_13 (64-bit)
  • Node.js 0.10.16 (64-bit)
  • Windows 7 (64-bit)

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

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Oct 16, 2013

Member

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

Member

paulvi commented Oct 16, 2013

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

@ghost ghost assigned paulvi Oct 16, 2013

@paulvi

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Oct 16, 2013

Member

@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.

Member

paulvi commented Oct 16, 2013

@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

This comment has been minimized.

Show comment
Hide comment
@zamnuts

zamnuts Oct 16, 2013

@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

zamnuts commented Oct 16, 2013

@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

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Jan 1, 2014

Member

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.

Member

paulvi commented Jan 1, 2014

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

This comment has been minimized.

Show comment
Hide comment
@ihgreenman

ihgreenman Jan 31, 2014

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.

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

This comment has been minimized.

Show comment
Hide comment
@ihgreenman

ihgreenman Jan 31, 2014

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

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

This comment has been minimized.

Show comment
Hide comment
@ihgreenman

ihgreenman Jan 31, 2014

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.

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

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Feb 3, 2014

Member

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?

Member

paulvi commented Feb 3, 2014

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 added a commit that referenced this issue Feb 3, 2014

@paulvi

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Feb 3, 2014

Member

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');
}
Member

paulvi commented Feb 3, 2014

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

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Feb 3, 2014

Member

@zamnuts example also works (on Windows)

Member

paulvi commented Feb 3, 2014

@zamnuts example also works (on Windows)

@ihgreenman

This comment has been minimized.

Show comment
Hide comment
@ihgreenman

ihgreenman Feb 3, 2014

@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, 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

This comment has been minimized.

Show comment
Hide comment
@paulvi

paulvi Feb 4, 2014

Member

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 .

Member

paulvi commented Feb 4, 2014

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 .

@palcocer

This comment has been minimized.

Show comment
Hide comment
@palcocer

palcocer Feb 19, 2014

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

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

This comment has been minimized.

Show comment
Hide comment
@Stelminator

Stelminator Jun 28, 2016

@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?

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment