-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
TypeError when running Next.js app with middleware and latest @sentry/nextjs package #8416
Comments
Hey, thanks for raising this. Could you provide a reproduction example? I can't reproduce this in my test app. Thanks! |
Sorry for not sending a complete reproduction example. I found the problem. My middleware was something like this: export const MAIN_DOMAIN = "http://maindomain.com"
export default async function middleware() {
return NextResponse.next()
} and I was importing it in another file: import { MAIN_DOMAIN } from '../middleware' it seems like importing anything from the middleware causes this error. I hope this helps anybody else 🙏🏽 . Thanks! |
Found this after 5hrs of debugging 🤧 Thanks a lot ! |
Ah, I finally see the problem. We only export the middleware wrapper from the edge runtime part of the SDK. When you import something from the middleware file that uses the node runtime the middleware wrapper is undefined. We need to fix this. Thanks for raising this! |
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
7.56.0
Framework Version
18.2.0
NextJs Version
13.3.0
Link to Sentry event
https://the-issue.sentry.io/issues/4280470356/events/7bda08795e7f48a1aad62e56be27ad80/
SDK Setup
sentry.edge.config.ts
sentry.server.config.ts
sentry.client.config.ts
Steps to Reproduce
npx create-next-app@latest
) with a simple middleware handler:This same error happened in this issue #6858 but the fix they added seems not to work on my side.
Expected Result
Enter to the page without any error.
Actual Result
I'm getting this exact error also when I deploy it to vercel, so it's not just a local error.
The text was updated successfully, but these errors were encountered: