Use Domains for exception-handling requests #3

hostilefork opened this Issue Jul 22, 2014 · 0 comments


None yet
1 participant

hostilefork commented Jul 22, 2014

Currently, it is the case that if a request is being processed and an error is thrown, the Node process will end; rendering the server unable to accept requests.

The deployment at Nodejitsu restarts the process for the next request. However this is time consuming and not as good as returning a proper "Server Internal Error" message. Also--any exception in one request would take down any requests with pending processing that could have otherwise continued without error.

There didn't seem to be any real way to work around this in the beginning, and I made a note about it. Following up now for the article Handling Internal Errors (and Bad Requests) in Node, I found an answer in response to someone else asking that question:

So long story short is that this problem may well be addressed with a new feature added to Node, called Domains:

Domains provide a way to handle multiple different IO operations as a single group. If any of the event emitters or callbacks registered to a domain emit an error event, or throw an error, then the domain object will be notified, rather than losing the context of the error in the process.on('uncaughtException') handler, or causing the program to exit immediately with an error code.

Assuming this is the correct methodology for how the top level request exception handling is managed, I should be using it.

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