Skip to content

Error logging not working when using Nextjs with SSG #8862

Closed
@immsfd

Description

@immsfd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions