Description
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
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:
A workaround is to wrap all API routes with another callback that always performs await res.end()
before returning.