Skip to content

[feat] Disabling internal error response handling? #1881

@joepie91

Description

@joepie91

Describe the feature

I am currently trying to add support to budo-express for Koa applications, and to that end I need to be able to pass a req/res to the Koa app for handling, and regain control in budo-express afterwards. This almost works by getting a server callback from app.callback() and invoking that, but the case where it's failing is when an unhandled error occurs within the application.

Currently, Koa internally handles those unhandled errors (in handleRequest) by sending an "Internal Server Error" response to the client and closing the response, and there seems to be no option to turn this off; this means that even though budo-express nominally gains control afterwards, it can no longer write a response to the client, which breaks its internal error handling (which is more verbose in development mode than Koa is).

Could some sort of option be added to Koa to disable this internal error handling, particularly the response sending/closing? I don't have control over the initialization process of the Koa app (it gets passed as an argument in already-initialized state), so to work in my case, it would need to be an option that can be set on an already-initialized app.

Alternatively, is there some kind of workaround to make this work (that doesn't involve inlining a whole copy of the respond helper function into my codebase, as is the case when trying to replicate a modified handleRequest)?

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions