I created a sample to post data to a rest services and I found out that when I have non-ascii or non-latin character (please see data.firstName), my post request using TEST-
The problem is that if you don't handle this error and keep the server alive, this remote crash exploit could be used for a DOS attack. However, you can handle it and continue on, and still shut down the process when unhandled exceptions occur (which prevents you from running in undefined state -- a very bad thing).
The connect module handles the error and calls next()
, sending back an object with the message body and status = 400
. In your server code, you can add this after express.bodyParser()
:
var exit = function exit() {
setTimeout(function () {
process.exit(1);
}, 0);
};
app.use(function (error, req, res, next) {
if (error.status === 400) {
log.info(error.body);
return res.send(400);
}
log.error(error);
exit();
});