今天碰到一个很奇怪的问题,就是在代码中抛出一个异常时node进程居然不会退出,throw的内容会作为respose内容,且通过uncaughtException事件还无法捕获,请各位大侠指点.
app.use(function(req,res,next){
throw 'error';
})
大家讲道理2017-04-17 14:24:53
Express catches the exception in the outer layer and processes the exception information and outputs it to the response.
The web framework definitely does not trust user code. All calls to user code have try catch, so as to ensure the stability of the service.
In a single-process single-thread environment like nodejs, an exception process will hang.