Last active
December 15, 2015 12:19
-
-
Save mikefrey/5259691 to your computer and use it in GitHub Desktop.
New Relic node module swallows on uncaught exceptions. Tested on node.js v0.8.22.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newrelic = require('newrelic') | |
var http = require('http') | |
function handleRequest(req, res) { | |
console.log('Handling request') | |
// Swallows the exception on the next line. | |
// Should throw a runtime error instead since DiesHere is undefined. | |
var x = DiesHere | |
res.end() | |
} | |
var server = http.createServer(handleRequest.bind(this)) | |
server.listen(1337, function(){ | |
process.nextTick(makeRequest) | |
}) | |
function makeRequest() { | |
http.get('http://localhost:1337/', function(res) { | |
console.log('Response received.') | |
process.exit(0) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you add something like this it should give you the exit your looking for:
process.on('uncaughtException', function(error){
console.error((new Date).toUTCString() + 'uncaughtException: '+error.message);
console.error(error.stack);
process.exit(1)
});