Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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:
export const POST = wrapApiHandlerWithSentry(async (req: NextRequest): Promise<Response> => {
// ...
}, "/my/route");
Steps to Reproduce
-
Call API route via fetch in the browser.
-
Observe:
POST /my/route 500 in 17012ms ⨯ TypeError: Cannot create proxy with a non-object as target or handler at eval (webpack-internal:///(rsc)/../../node_modules/@sentry/nextjs/build/cjs/common/wrapApiHandlerWithSentry.js:78:29) at eval (webpack-internal:///(instrument)/../../node_modules/@sentry/node/node_modules/@sentry/opentelemetry/build/cjs/index.js:885:15) at Object.handleCallbackErrors (webpack-internal:///(instrument)/../../node_modules/@sentry/core/build/cjs/utils/handleCallbackErrors.js:26:26) at eval (webpack-internal:///(instrument)/../../node_modules/@sentry/node/node_modules/@sentry/opentelemetry/build/cjs/index.js:884:19)
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.
Metadata
Metadata
Assignees
Type
Projects
Status