Skip to content

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

Closed

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

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 18, 2025
  2. Lms24 commented on Aug 21, 2025

    @Lms24
    Member

    Hi, thanks for writing in! We'll take a look at this next week (Sentry is doing a company-wide hackathon ("Hackweek") this week).

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Aug 21, 2025
  4. cbovis commented on Aug 25, 2025

    @cbovis

    Also seeing this. A good way to reproduce is with a route which uses some static path params and a dynamic params fallback. The paths associated to the static params are pregenerated fine but hitting the route with a dynamic param will surface the error immediately so you don't need to wait on revalidate times. Disabling sendDefaultPii also fixes for me.

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 25, 2025
  6. self-assigned this
    on Aug 25, 2025
  7. chargome commented on Aug 25, 2025

    @chargome
    Member

    Build the app and navigate to a page with revalidate set

    Are you referring to setting next: { revalidate: SOME_NUMBER }?

    Also I could not reproduce it, can someone create a reproduction repository for this?

  8. 13 remaining items

  9. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 24, 2025
  10. chargome commented on Sep 24, 2025

    @chargome
    Member

    @karlkeefer are you building your app with webpack or turbopack?

  11. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 24, 2025
  12. karlkeefer commented on Sep 24, 2025

    @karlkeefer

    @chargome we are using webpack.

  13. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 24, 2025
  14. chargome commented on Sep 24, 2025

    @chargome
    Member

    Thanks for confirming. I'm leaning towards entirely reverting the logic for extracting the url in webpack as this will never work for turbopack due to missing build instrumentation. We'll likely need to find a different approach here that works for both bundlers.

    fyi @RulaKhaled

  15. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 24, 2025
  16. github-actions commented on Nov 10, 2025

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #18113, which was included in the 10.24.0 release.

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