Skip to content

Koa errorHandler should not fail with non number error.code #2785

@Mairu

Description

@Mairu

ctx.response.status = error.code || 500

When an error with a code that is not a number is thrown and caught here, the following error appears

  AssertionError [ERR_ASSERTION]: status code must be a number
      at Object.set status [as status] (\projectname\node_modules\koa\lib\response.js:86:5)
      at \projectname\node_modules\@feathersjs\koa\src\handlers.ts:12:24
      at async serve (\projectname\node_modules\koa-static\index.js:53:9)
      at async cors (\projectname\node_modules\@koa\cors\index.js:108:16)

It should be checked if the error.code is a number (or a valid status code) before using it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions