Skip to content

[@sentry/nextjs] Errored API routes trigger "API resolved without sending a response" #3852

Description

@adarnon

Package + Version

  • @sentry/nextjs

Version:

6.10.0

Description

Describe your issue in detail, ideally, you have a reproducible demo that you can show.

The withSentry() API route wrapper monkeypatches res.end() function to await for flush before closing a request. While this is certainly useful for serverless environments, it could cause a false positive warning on deployments with a custom server (e.g., Express).

Since normal Next API route code does not await for res.end() to finish, the handler's promise returns before the response has ended properly. This causes Next to detect the API route as having finished without a response, even though the response is sent a few moments later. Here is an example:

imageedit_3_8075703349

A workaround is to wrap all API routes with another callback that always performs await res.end() before returning.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions