Skip to content
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

I don't receive errors in Sentry but they're logged in the #13538

Closed
3 tasks done
TheCukitoDev opened this issue Aug 30, 2024 · 5 comments
Closed
3 tasks done

I don't receive errors in Sentry but they're logged in the #13538

TheCukitoDev opened this issue Aug 30, 2024 · 5 comments
Assignees
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK

Comments

@TheCukitoDev
Copy link

TheCukitoDev commented Aug 30, 2024

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

Framework Version

Next 14.2.4

Link to Sentry event

No response

Reproduction Example/SDK Setup

You can go to my repo

Steps to Reproduce

  1. Clone repo
  2. Add test keys
  3. bun dev
  4. go to http://localhost:3000/sentry-example-page
  5. send an error

Expected Result

Should log error in sentry. But nothing happens.

Actual Result

It should appear a error in sentry page but only appears in my console. I don't know if it is because of the t3 stack. This is T3 stack. Sorry but i recorded video while listening music.

20240830-1005-29.5159419.mp4
@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Aug 30, 2024
@Lms24
Copy link
Member

Lms24 commented Aug 30, 2024

Hey @TheCukitoDev thanks for writing in! I can't start your reproduction because I'm missing a bunch of API keys to even get to the sentry example page. Can you email them to me (see address in my profile)? Otherwise please provide a reproduction that doesn't require all these keys, thanks!

Without being able to test this myself I can only give some superficial suggestions:

  • Have you tried using npm instead of bun?
  • I see your DSN points to the DE region. Have you tried creating a US region project and using this DSN? Does it make any difference?
  • When you enable debug: true in your Sentry.init calls, do you get any logs that suggest a problem? from the video (nice music btw 😅 ) I can see that requests are made but maybe the logs can tell us more.

@TheCukitoDev
Copy link
Author

Hello, I changed the .env.example in the commit c947adf. The only required env variables are the ones that are public and the sentry one (i think you should have one to debug them). The resend, openai and clerk keys doesen't matters. They can just be bypassed by using some fake keys like sk_xxxx or stc_xxxxxx. If you change the .env.example by .env it should work well but you aren't going to be able to use any of the services like clerk. If you have troubles with clerk only remove dependencie. I didn't had any issue while testing the env variables I used in .env.example as .env. Thanks for help. Also do bun install i missed it last time

@Lms24
Copy link
Member

Lms24 commented Sep 2, 2024

Hey @TheCukitoDev, I finally got the reproduction working. Had to remove the middleware.ts file because even with the dummy clerk CLERK_SECRET_KEY I'd get errors. But anyway...

It looks like the problem is not the Sentry SDK in this case but the the next.config.cjs file. The .cjs file extension only is supported in version 14 but only got added in a recent 15 canary release (via vercel/next.js#63051).

So in your case, your next.config file was simply ignored. You can verify this independently of Sentry by removing everything from this file and just logging something to the console. It won't appear.

To fix this:

  1. Rename your file to next.config.js
  2. Clean up the mixture of import and require syntax in the file (otherwise you'll get build and dev server errors anyway)
    For example:
    /** @type {import("next").NextConfig} */
    const config = {};
    
    import { withSentryConfig } from "@sentry/nextjs";
    
    export default withSentryConfig(config, {
      //...
    });

Judging by the comment left by the wizard, it looks like our wizard might have detected the wrong JS flavour and added our CJS code snippet instead of the ESM variant. But it's hard to say this with certainty without knowing how this file looked before adding Sentry.

So with these fixes in place, I got errors and spans/transactions in the Sentry UI.

I'm going to close this issue for the time being as I believe this should be fixed. Please let me know if you have further questions or think this needs to be reopened. Thanks!

@TheCukitoDev
Copy link
Author

Thanks. It works perfectly. I changed the .js to the .cjs because in the package.json it says .js refers to ES6 so it should be .cjs in my mind to made it works. Thanks

@Lms24
Copy link
Member

Lms24 commented Sep 2, 2024

.js is treated as ESM because your package.json has type: module set. Otherwise it'd default to CJS :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK
Projects
Archived in project
Development

No branches or pull requests

2 participants