New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
throw in Async route #81
Comments
Hi @victor-a-rigacci , can you detail a bit more what crash the server means? Can you please have a look at this example: https://github.com/jkyberneees/ana/blob/master/demos/error-handler.js |
I'm having the same problem when environment is Production. On development is working like a charm but in production is throwing and crash ignoring the "errorHandler". |
Hi @sarriaroman, I would need to know more details on your service configuration. I can tell you nor You can confirm with this example: 'use strict'
process.env.ENV = 'PRODUCTION'
const service = require('../index')({
errorHandler (err, req, res) {
console.log(`Unexpected error: ${err.message}`)
res.send(err)
}
})
service.use(async (req, res, next) => {
try {
await next()
} catch (err) {
return next(err)
}
})
service.get('/throw', (req, res) => {
throw new Error('Upps!')
})
service.use('/nested', router)
service.start() It might be that you are registering connect like middlewares that are not returning service.use(async (req, res, next) => {
try {
await next()
} catch (err) {
return next(err)
}
}) Regards |
Hi, work perfectly thanks! |
Hello. I am also had the same issue. Would recommend to put this snippet into docs. service.use(async (req, res, next) => {
try {
await next()
} catch (err) {
return next(err)
}
}) |
Hi @deman4ik thanks for your remark on this. Let me explain the reason for this issue, also I will add it to the readme. Some middlewares don't do In Thank you all for reporting. |
If i throw an error on async function crash the server.
The text was updated successfully, but these errors were encountered: