-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Using wrapApiHandlerWithSentry
after upgrading to @sentry/nextjs 8.x results in API routes failing with TypeError
#12865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, since you are using an App Router API route, you probably want to use I opened a PR to make this more clear in the JSDoc. |
@lforst should the migration guide call this out? It was surprising to see it go from working in 7.x to causing 500 errors on those routes in 8.x. |
This cannot have worked in v7 I think, since this API has not been changed in v8. Unless something escapes me... There were a couple of renamings but those are in the migration guide. Are you sure you simply bumped and didnt change anything else? |
The commit that bumped Sentry only bumped Sentry - though we were on a version prior to #6726 being closed, so there were some idiosyncracies with Next.js App Router support. |
@AaronFriel is this still an issue for you after implementing @lforst's suggestion? |
Removing the wrapper entirely worked, as we can rely on auto instrumentation now. It looks like the function might be double wrapped. |
Closing this for now then, feel free to open up another issue for that if needed. |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/nextjs
SDK Version
8.15.0
Framework Version
Next 14.2.1
Link to Sentry event
n/a
SDK Setup/Reproduction Example
Install Sentry using
@sentry/nextjs
, and wrap an API route:Steps to Reproduce
Call API route via fetch in the browser.
Observe:
Expected Result
Upgrading to
@sentry/nextjs
from 7.x to 8.x should not have resulted in 500 errors, especially after following the migration guide.We previously used
wrapApiHandlerWithSentry
as Next.js 13 and 14 App Router route handlers were not automatically instrumented. The commit we added this call in linked to the tracking issue for App Router support, #6726. It looks like in upgrading our version of the Sentry SDK, this was fixed.Actual Result
All API routes wrapped with
wrapApiHandlerWithSentry
return 500s and the type error above is thrown. It appears that this wrapping function and/or auto-instrumentation conflict.This code appears relevant, but I'm not familiar with Sentry internals to say for sure:
sentry-javascript/packages/utils/src/object.ts
Lines 29 to 33 in 3549777
The error called out here is similar to the error we saw.
The text was updated successfully, but these errors were encountered: