Skip to content

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

@adarnon

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.

Metadata

Metadata

Assignees

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions