Skip to content

Conversation

@logaretm
Copy link
Collaborator

@logaretm logaretm commented Nov 12, 2025

Summary

ISR pages will have a sentry-trace and baggage meta tags rendered on them following the initial render or after the first invalidation causing a cached trace id to be present until the next invalidation.

This happens in Next.js 15/16 and both on Turbopack and Webpack.

Implementation

I Found no way to conditionally set/unset/change the values set by the clientTraceMetadata option, I found nothing useful on unit async storages, nor re-setting the propagation context works. The clientTraceMetadata gets called way earlier at the app-render.tsx level, so we cannot change it per page as it has already run.

so this is a bit of a workaround, I decided to do it on the client side by:

  • Marking ISR page routes via the route manifest we already have.
  • In Sentry.init call we remove the tags before the browser integration has had a chance to grab the meta tags.

Not the cleanest way, but I verified the issue by writing tests for it and making sure that the solution does resolve them.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.6 kB - -
@sentry/browser - with treeshaking flags 23.09 kB - -
@sentry/browser (incl. Tracing) 41.26 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.53 kB - -
@sentry/browser (incl. Tracing, Replay) 79.73 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.4 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84.42 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.58 kB - -
@sentry/browser (incl. Feedback) 41.27 kB - -
@sentry/browser (incl. sendFeedback) 29.27 kB - -
@sentry/browser (incl. FeedbackAsync) 34.2 kB - -
@sentry/react 26.29 kB - -
@sentry/react (incl. Tracing) 43.22 kB - -
@sentry/vue 29.09 kB - -
@sentry/vue (incl. Tracing) 43.03 kB - -
@sentry/svelte 24.61 kB - -
CDN Bundle 26.9 kB - -
CDN Bundle (incl. Tracing) 41.81 kB - -
CDN Bundle (incl. Tracing, Replay) 78.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.81 kB - -
CDN Bundle - uncompressed 78.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 124 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 240.03 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 252.79 kB - -
@sentry/nextjs (client) 45.46 kB +0.27% +121 B 🔺
@sentry/sveltekit (client) 41.64 kB - -
@sentry/node-core 50.81 kB - -
@sentry/node 157.99 kB - -
@sentry/node - without tracing 92.69 kB - -
@sentry/aws-serverless 106.45 kB - -

View base workflow run

@logaretm logaretm force-pushed the awad/js-1152-nextjs-incremental-static-rendering-causes-cached-trace-id branch from 73ec1ba to 54be3bf Compare November 12, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nextjs incremental static rendering causes cached trace id, leading to merged client-side transactions from different users/requests

2 participants