Crashing micro when throwing errors on Promises
olivermaldonado opened this issue · comments
Oliver commented
The router causes micro to crash when errors are thrown on Promises.
module.exports = router(
get('/badError', (req, res) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
throw new Error('deferred error')
}, 1000)
})
}),
get('goodError', (req, res) => {
throw new Error('immediate error')
})
)
Is this intended behavior?
One of the advantages of using micro is it's error handling. This issue breaks that.
Kristjan Broder Lund commented
This is not an error with micro-router or micro.
The deferred error is thrown from the context of the setTimeout callback which is not in the promise chain.