eggjs / egg

🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
https://eggjs.org
MIT License
18.89k stars 1.81k forks source link

中间件无法捕获egg全局异常! #4051

Closed bhb4157 closed 4 years ago

bhb4157 commented 4 years ago

现在我们公司内部egg服务会经常去调用第三方服务,有些超时很久都不返回导致内部服务异常,我用中间件捕获异常但还是没有捕获到这种超时异常,请问有没有更加合理的捕获遗漏异常的方式。

Jeff-Tian commented 4 years ago

通过 error 事件监听?

app.on('error', error=>{...}) 
atian25 commented 4 years ago

大概率是你代码写错,鉴于你没有给出复现方式,我们也只能祝你好运!

bhb4157 commented 4 years ago

在路由第一个中间件加了全局错误捕获,然后统一异常提示返回,我在线上再观察一段时间,目前异常都能被这个中间件拦截到。

atian25 commented 4 years ago

hey, we need more information to follow up this issue, recommend using npm init egg --type=simple to provide a mini project and upload to your GitHub.

for now, it will close due to lack of activity, feel free to reopen this issue if provided more information.