Uncaught async errors in pre-handlers
I've noticed that uncaught errors from async handlers are now handled by the framework, courtesy of #3486.
Will a similar behavior also be applied onto pre handlers? Anything that executes in the pre phase seems to have the same input arguments and design conventions, so I was curious if this was an issue.
For example:
{
method: 'GET',
path: '/Items',
config: {
pre: [{
assign: 'test',
method: async function(request, reply) {
throw new Error();
}
}]
}
}
It applies to other extension points (onRequest, onPreHandler, etc.) where this could also be very handy.
@jeff3yan this ~will no longer be~ is no longer an issue in Hapi 17 (now in beta), as it'll remove all callback-style APIs and adopt Promises for all async methods.
I am not going to add any new support for async/await/Promises in hapi v16. You will need to wait for v17 for proper and consistent handling of them.