joyent/node — Issue #2677: process.on('uncaughtException' can NOT be used to send mail
Author: thakkar-rushikesh
Created: 2012-02-02 12:04:52+00:00
State: open

I wanted to send an email when my node behaves badly. I thought of using "process.on('uncaughtException')" to do the same. Below is the code snippet:
...
...
process.on('uncaughtException', function(err) {
console.error("Error Occurred: " + err);
mailhelper.email('Error: ', err);	// I have wrapped email sending functionality inside mailhelper.js
});

When I execute this, it prints the error log on the console, but doesn't execute the next line. It doesn't even print any informative message describing why it is NOT sending email.
I even swapped the lines to check if it would execute only the 1st line (!), but that too won't help.

I think this is a common scenario, and should be working.