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

Error logging not working when using Nextjs with SSG #8862

Closed
3 tasks done
mattkrco opened this issue Aug 23, 2023 · 2 comments
Closed
3 tasks done

Error logging not working when using Nextjs with SSG #8862

mattkrco opened this issue Aug 23, 2023 · 2 comments
Labels
Package: nextjs Issues related to the Sentry Nextjs SDK Type: Bug

Comments

@mattkrco
Copy link

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.64.0

Framework Version

7.64.0

Link to Sentry event

No response

SDK Setup

import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: "mydsn",

// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1,

// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,

replaysOnErrorSampleRate: 1.0,

// This sets the sample rate to be 10%. You may want this to be 100% while
// in development and sample at a lower rate in production
replaysSessionSampleRate: 0.1,

// You can remove this option if you're not planning to use the Sentry Session Replay feature:
integrations: [
new Sentry.Replay({
// Additional Replay configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
});

Steps to Reproduce

  1. Create a next project using yarn create next-app and the following responses:
√ Would you like to use TypeScript? ... No / Yes
√ Would you like to use ESLint? ... No / Yes
√ Would you like to use Tailwind CSS? ... No / Yes
√ Would you like to use `src/` directory? ... No / Yes
√ Would you like to use App Router? (recommended) ... No / Yes
√ Would you like to customize the default import alias? ... No / Yes
  1. Add sentry using npx @sentry/wizard@latest -i nextjs
  2. Add http-server using yarn add http-server
  3. In pages/index.js, remove everything related to 'next/image'
  4. Add the following to package.json under scripts: "export": "next build && next export",
  5. Run yarn dev, navigate to /sentry-example-page, click the Throw error! button, and it will show up in sentry
  6. Next run yarn export and then http-server ./out. Navigate to the same page and click the Throw error! button

Expected Result

I am expecting that sentry works when running nextjs as a static site. These issues seem to imply that it is possible:

#6088

#6255

#3761

However I could be wrong, and couldn't specifically verify in the documentation if sentry should work in this use case.

Actual Result

No result shows up in sentry. Instead, the static site is trying to make a call to the http-server, which unsurprisingly fails. I would have expected this to be handled on the client.

image

@github-actions github-actions bot added the Package: nextjs Issues related to the Sentry Nextjs SDK label Aug 23, 2023
@lforst
Copy link
Member

lforst commented Aug 24, 2023

Hi, when doing next export the tunnelRoute option will not work, as you don't have a server that is running. You should just be able to remove that option.

@mattkrco
Copy link
Author

ahhh perfect, that works, thanks!

For any future googlers, that's configured in next.config.js. Make sure you have any ad blockers disabled while testing, and if you don't want to have these reports potentially blocked by ad blockers, review this section:

https://docs.sentry.io/platforms/javascript/guides/nextjs/troubleshooting/#dealing-with-ad-blockers

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 Type: Bug
Projects
Archived in project
Development

No branches or pull requests

2 participants