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

Crash if exception was thrown in cluster "master". #2556

Closed
rdner opened this issue Jan 17, 2012 · 3 comments
Closed

Crash if exception was thrown in cluster "master". #2556

rdner opened this issue Jan 17, 2012 · 3 comments
Labels

Comments

@rdner
Copy link

rdner commented Jan 17, 2012

I use exceptions for logging any errors in my code, but if I catch errors like this:

process.on('uncaughtException', function (error) {
    logger.error(error);
});

and then use cluster, my server crashes if exception was thrown in "master" (but logger write message).

Can I catch errors in "master" as exceptions and don't crash cluster?

@AndreasMadsen
Copy link
Member

This is because of https://github.com/joyent/node/blob/v0.6/lib/cluster.js#L90, the only thing you can do is:

var cluster = require('cluster');
var child = cluster.fork();

// master has now been setup
process.removeAllListeners('uncaughtException');
process.on('uncaughtException', function (error) { logger.error(error); });

In node 0.8 we could properly check if there are more that one event lisenter before killing the process.

Internal reference #2038

@rdner
Copy link
Author

rdner commented Jan 17, 2012

Thank you for help!

@bnoordhuis
Copy link
Member

I've landed a fix for this bug in d44ce97.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants