Uncaught Exceptions on the server, best practice?

What are the best practices in Meteor for stopping server-side app crashes due to uncaught exceptions?

My current issue, an API provider for us, is rarely (for unknown reasons) not returning JSON data, causing JSON.parse(body) in the GET function callback to throw the error:

SyntaxError: Unexpected end of input

This takes down the server. Now this itself is a fairly easy fix, but went unnoticed until it happened. So my question is, is there a way to log errors like this, without Meteor itself failing fast?

Obviously, I don’t want to put every single function in a try catch block. We are running a custer, so the app doesn’t fully go down, but will break things for people on that instance. Vs domains/cluster in node which I believe handles remaining requests first?

I’m just wondering how other people solve this issue, or do you in fact write try/catch or other checks for every piece of data too?

PS. These are just regular functions in Meteor/Node, not tied into Meteor.call or fibers or anything fancy like that.

Thanks!

You could look into using Node’s process.on('uncaughtException', ...) functionality.