mcavage/node-restify — pull request #534 by balihoo-anewman (2014-02-18 00:28:27+00:00)
Title: Prevent the server from hanging when a non-Error, non-string argument is given to next().

When something is passed to next() that is not an Error or a string, the server will hang indefinitely. This change will make it at least clear what has happened, instead of hanging, which was difficult to debug.

Here's an example server that reproduces the issue I had.

var restify = require('restify');
var server = restify.createServer();

server.get('/error', function(req, res, next){
next(new Error('Error!'));
});

server.get('/hangs', function(req, res, next){
next({message: 'Error!'});
});

server.listen(8000, function(){
console.log('Listening on', server.url);
});

Before this commit, accessing `/error` would produce `{"message":"Error!"}`, and accessing `/hangs` would hang indefinitely. After this commit, both `/error` and `/hangs` produce `{"message":"Error!"}`.

Thanks.