Also, everything within the `if(_.isUndefined...) { ... }` block is probably better off moved outside the `try` block to limit the number of things that can throw exceptions and do weird things like double-close the socket or double-write the error response.