Skip to content

fix(nextjs): Keep unsampled prerenders free of per-render meta tags - #27009

Merged
chargome merged 1 commit into
developfrom
fix/nextjs-unsampled-prerender-meta-tags
Dec 1, 2026
Merged

chargome merged 1 commit into
developfrom
fix/nextjs-unsampled-prerender-meta-tags

Conversation

@chargome

@chargome chargome commented Dec 1, 2026

Copy link
Copy Markdown
Member

What

A prerender that is not sampled now writes an empty sentry-cache-origin tag and no sentry-render-start tag. Sampled prerenders are unchanged.

Why

The client ignores the trace of an unsampled prerender, so the two values only made the HTML of every ISR regeneration differ from the previous one. Vercel bills a regeneration as a write only when its output changed, so this cost users money for nothing. The tradeoff is that pageloads of pages from an unsampled prerender no longer report page.server_rendering.age. They keep page.server_rendering.type.

Refs: #27002

A prerender wrote its trace and start time into the HTML even when it
was not sampled. The client ignores an unsampled trace, so the values
only made every ISR regeneration differ from the previous one, which
Vercel bills as a write. An unsampled prerender now writes an empty
`sentry-cache-origin` tag and no `sentry-render-start` tag.

Refs #27002

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 382ef3b (PR test merge using develop at 0c4dd26)

Against: 0c4dd26 (develop) · base run #68418

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.58 kB - -
@sentry/browser - with treeshaking flags 28.76 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.63 kB - -
@sentry/browser (incl. Tracing) 53.72 kB - -
@sentry/browser (incl. Tracing Core) 40.65 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.72 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.6 kB - -
@sentry/browser (incl. Tracing, Replay) 93.64 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.43 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 98.49 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.45 kB - -
@sentry/browser (incl. Feedback) 48.43 kB - -
@sentry/browser (incl. sendFeedback) 31.15 kB - -
@sentry/browser (incl. FeedbackAsync) 36.2 kB - -
@sentry/browser (incl. Metrics) 31.9 kB - -
@sentry/browser (incl. Logs) 32.18 kB - -
@sentry/browser (incl. Metrics & Logs) 32.84 kB - -
@sentry/react 32.6 kB - -
@sentry/react (incl. Tracing) 56.45 kB - -
@sentry/vue 38.78 kB - -
@sentry/vue (incl. Tracing) 56.74 kB - -
@sentry/svelte 30.61 kB - -
@sentry/effect (client) 42.27 kB - -
@sentry/effect (client, incl. Tracing) 55.01 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.34 kB - -
@sentry/remix (Remix 3 client bundle) 59.46 kB - -
CDN Bundle 32.4 kB - -
CDN Bundle (incl. Tracing) 54.09 kB - -
CDN Bundle (incl. Logs, Metrics) 35.16 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.55 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.12 kB - -
CDN Bundle (incl. Tracing, Replay) 91.88 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.41 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.35 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.82 kB - -
CDN Bundle - uncompressed 94.64 kB - -
CDN Bundle (incl. Tracing) - uncompressed 159.96 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.98 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.59 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.37 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.39 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 288.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.95 kB - -
@sentry/nextjs (client) 60.27 kB - -
@sentry/sveltekit (client) 55.07 kB - -
@sentry/astro (client) - rolldown, without tracing 39.51 kB -0.01% -1 B 🔽
@sentry/core/server 45.88 kB - -
@sentry/core/browser 14.49 kB - -
@sentry/node 157.94 kB -0.01% -2 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.59 kB - -
@sentry/node - without tracing 89.97 kB - -
@sentry/node - without channel injection 146.9 kB - -
@sentry/aws-serverless 100.62 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 212.5 kB - -
@sentry/cloudflare (withSentry) 492.68 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 215.45 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.77 kB +0.02% +44 B 🔺

View base workflow run

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Optional E2E tests

All optional checks were successful. 7 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details

@chargome chargome self-assigned this Dec 1, 2026
@chargome
chargome added this pull request to stack #27012 December 1, 2026 09:48
@chargome
chargome marked this pull request as ready for review December 1, 2026 09:52
@s1gr1d

s1gr1d commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

This is fixing it for Next.js but we probably have the same problem in SvelteKit and Nuxt. They behave they same and they could also be deployed on Vercel. I think we should rather fix this for all in the end.

Maybe we can modify _INTERNAL_getCacheOriginMetaTags (unsampled -> no meta tag). Or we should rather write an empty sentry-cache-origin tag and only drop sentry-render-start, because the client sets page.server_rendering.type only when that tag exists, and an empty tag doesn't change between renders anyway. When there's no tag at all, it means the server rendered this page dynamically.

@chargome

chargome commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Next.js does not use _INTERNAL_getCacheOriginMetaTags, it writes the tags through its own propagator, so the helper is a separate code path. I fixed it in a follow-up, #27017, using your second variant (empty sentry-cache-origin, no sentry-render-start).

@chargome
chargome merged commit 7f296d8 into develop Dec 1, 2026
131 checks passed
@chargome
chargome deleted the fix/nextjs-unsampled-prerender-meta-tags branch December 1, 2026 12:25
chargome added a commit that referenced this pull request Dec 1, 2026
## What

Adds a `deterministicPrerenders` option to `withSentryConfig`. With it,
no prerender writes its trace or start time into the HTML, so the output
of an ISR regeneration stays identical when the content did not change.

## Why

After #27009, a sampled prerender still changes the HTML on every
regeneration, which Vercel bills as an ISR write. Users with large pages
or a high sample rate need a way to turn that off. The option costs the
`cache_origin` link and `page.server_rendering.age` on pageloads of
prerendered pages, so it is off by default. Pageloads keep
`page.server_rendering.type`.

Stacked on #27009.

Closes: #27002

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
chargome added a commit that referenced this pull request Dec 1, 2026
…a tags (#27017)

## What

SvelteKit and Nuxt pages rendered by an unsampled request now get an
empty `sentry-cache-origin` tag and no `sentry-render-start` tag.
Sampled renders and pages prerendered in the build are unchanged.

## Why

Follow-up to #27009, which fixed this for Next.js only. SvelteKit and
Nuxt write the tags through a shared helper in core with the same
problem: an unsampled render changed the cached HTML on every
regeneration, which Vercel bills as an ISR write. The tag stays, with
empty content, so pageloads keep `page.server_rendering.type`. They lose
`page.server_rendering.age` for unsampled renders.

Stacked on #27010.

Refs: #27002

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
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.

2 participants