AdonisJS is a TypeScript-first web framework for building web apps and API servers. It comes with support for testing, modern tooling, an ecosystem of official packages, and more.
While I was setting up a page for status 404 for my project, I noticed that the page was not rendered when a non registered route is accessed even in a production environment or with disableStatusPagesInDevelopment = false setted on ExceptionHandler. So I decide to look for examples of same issues. Here are some issues that i founded:
if (ctx['view'] && this.expandedStatusPages[error.status]) {
const html = ctx['view'].render(this.expandedStatusPages[error.status], { error })
ctx.response.status(error.status).send(html)
return ;
}
The method view.render() above returns a promise, so the await operator is missing.
So, when inserting the operator the page was rendered correctly.
I assume that this error was not detected in the test for the following cause: in the test only the statusCode validation of the response is done and if the view name matches what was set in statusPages, however the return of the view.render call is not validated .
While I was setting up a page for status 404 for my project, I noticed that the page was not rendered when a non registered route is accessed even in a production environment or with
disableStatusPagesInDevelopment = false
setted on ExceptionHandler. So I decide to look for examples of same issues. Here are some issues that i founded:But none of them has the real solution.
When looking in HttpExceptionHandler code i found the possible of the error
The method
view.render()
above returns a promise, so the await operator is missing. So, when inserting the operator the page was rendered correctly.I assume that this error was not detected in the test for the following cause: in the test only the
statusCode
validation of the response is done and if the view name matches what was set instatusPages
, however the return of theview.render
call is not validated .Package version
Node.js and npm version
Node.js v14.15.0 and npm v6.14.8
Sample Code (to reproduce the issue)
Are you willing to work on it with little guidance?
Yes, i can submit a PR for the correction.