Skip to content

Server cache not refreshing when sendDefaultPii: true since @sentry/nextjs@9.43 (DYNAMIC_SERVER_USAGE error) #17431

Description

@giovannetti-eric

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

9.43

Framework Version

Next 15.4.6

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  • Upgrade @sentry/nextjs from 9.42 (works) to 9.43+ (issue persists in 10.5).
  • Build the app and navigate to a page with revalidate set.
  • Observe that x-nextjs-cache transitions from STALE → HIT.
  • However, Server Component data does not update.
  • Console error:
    -- [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' }
    -- cache-control response header has s-maxage=30 (unexpected).
  • Downgrade back to 9.42 → issue disappears.
  • In sentry.server.config.ts, setting sendDefaultPii: false also resolves the issue.
// sentry.server.config.ts
import * as Sentry from "@sentry/nextjs";

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  environment: process.env.NEXT_PUBLIC_ENV,

  sendDefaultPii: true,
  sampleRate: 0.1,
  maxBreadcrumbs: 10,
});
// instrumentation.ts
import * as Sentry from "@sentry/nextjs";

export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    await import("../sentry.server.config");

    if (process.env.NEXT_PUBLIC_ENV !== "development") {
      await import("../logger.config");
      await import("../opentelemetry.config");
    }
  }

  if (process.env.NEXT_RUNTIME === "edge") {
    await import("../sentry.edge.config");
  }
}

export const onRequestError = Sentry.captureRequestError;

Expected Result

  • Server cache should revalidate correctly.
  • Enabling sendDefaultPii: true should not break caching.

Actual Result

  • With sendDefaultPii: true, cache never refreshes.
  • Server Component rendering fails with a cryptic DYNAMIC_SERVER_USAGE error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions