Skip to content

Nextjs: sendDefaultPii on sentry.server.config.ts breaks ISR pages #18097

@ahmed-fawzy99

Description

@ahmed-fawzy99

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. Have the sentry v10.22 installed on 15.5.3 wizard set up sentry on a project
  2. sentry.server.config.ts from the wizard setup will have this option: sendDefaultPii: true
  3. Build an ISR route on Next.js 15.5.3 (this example only pre-renders 250 pages, not all possible routes) like this:
interface Props {
  params: Promise<{ slug: string }>;
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { slug } = await params;
  const [video, videoError] = await tryCatch(fetchVideo(slug, true));

  if (videoError || !video) {
    return {
      title: 'Video not found',
      description: 'The requested video could not be found.',
    };
  }

  return {
    title: '...',
    description: '...',
    // rest of metadata
  };
}

export async function generateStaticParams() {
    const videos: SlugsResponse = await fetchVideoSlugs(250);
    return videos?.data?.map((video: string) => ({
      slug: video,
    }));
}

export default async function page({ params }: Props) {
  const { slug } = await params;
  const [video, videoError] = await tryCatch(fetchVideo(slug, true));

if (videoError || !video) {
    return <p>Error fetching the requested video</p>
  }

  return (
      {/* Rest of the page */}
  );
}
  1. Build and run the project
  2. Visit any page on that route that is either :
    a. Was not from the pre-rendered 250 example pages
    b. Does not exist (random slug)
  3. An 500 | INTERNAL SERVER ERROR is thrown on the visited page. Nextjs error log:
 ⨯ [Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: 'DYNAMIC_SERVER_USAGE'
}

sendDefaultPii parameter breaks the ISR generation, and setting its value to false resolves this issue. However, the bug root wasn't clear it was caused by Sentry, and should removed from the setup wizard and/or have a comment on it that this parameter breaks ISR.

Expected Result

Page should render the requested resource or throw 404 not found error, not 500 server error.

Actual Result

ISR page renders 500 | INTERNAL SERVER ERROR

Next.js logs:

 ⨯ [Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: 'DYNAMIC_SERVER_USAGE'
}

Product Area

Ingestion and Filtering

Link

No response

DSN

No response

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions