Skip to content

feat(nextjs): Add deterministicPrerenders build option - #27010

Merged
chargome merged 2 commits into
developfrom
feat/nextjs-deterministic-prerenders
Dec 1, 2026
Merged

chargome merged 2 commits into
developfrom
feat/nextjs-deterministic-prerenders

Conversation

@chargome

@chargome chargome commented Dec 1, 2026

Copy link
Copy Markdown
Member

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

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: edd7f4c (PR test merge using develop at 7f296d8)

Against: 7f296d8 (develop) · base run #68432

✅ 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% +3 B 🔺
@sentry/core/server 45.88 kB - -
@sentry/core/browser 14.49 kB - -
@sentry/node 157.98 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.6 kB - -
@sentry/node - without tracing 89.99 kB +0.01% +1 B 🔺
@sentry/node - without channel injection 146.94 kB +0.01% +1 B 🔺
@sentry/aws-serverless 100.65 kB +0.01% +3 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.93 kB +0.07% +159 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-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) 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, bun) 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-15 (turbo) Test (optional) Successful in 2m 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:53
Comment on lines +410 to +420
/**
* Keeps the HTML of a prerendered page identical between regenerations whose content did not change, so that a
* platform which bills ISR writes by changed output, such as Vercel, does not bill for them.
*
* By default, a page that a sampled request prerenders carries the trace and the start time of that prerender. The
* pageload of a visitor links the trace and reports the age of the page as `page.server_rendering.age`. With this
* option, prerendered pages carry neither, so their pageloads have no such link and no age. They are still marked
* with `page.server_rendering.type`.
*
* @default false
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rather focus on what that means for the user in the end. That they would loose the "Open linked trace" functionality in the UI, pageload and server being two separate traces without the link.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I reworded it.

*
* @default false
*/
deterministicPrerenders?: boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about linkCachedPageRenders (default true) so it's more focused on what impact it has for the user?

I am not a fan of deterministic here as (seeing it as a whole) Sentry has no power over a page being deterministically rendered or not. Within what Sentry touches, yes. But not for the whole application.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to keep the name. The option is for people who need stable ISR output, and that is what they will look for. If we later find other things Sentry writes that change per render, they belong under this flag too, and a name about the link would no longer fit. I added a line to the doc comment that this only covers what Sentry adds, not the whole page.

Base automatically changed from fix/nextjs-unsampled-prerender-meta-tags to develop December 1, 2026 12:25
A sampled prerender still writes its trace and start time into the HTML,
so its output differs on every ISR regeneration. With this option, no
prerender writes them, at the cost of the `cache_origin` link and
`page.server_rendering.age` on pageloads of prerendered pages.

Closes #27002

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@chargome
chargome force-pushed the feat/nextjs-deterministic-prerenders branch from f83fcfe to f2bcffc Compare December 1, 2026 12:25
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@chargome
chargome requested a review from s1gr1d December 1, 2026 12:29
@chargome
chargome merged commit ee0e8f1 into develop Dec 1, 2026
125 checks passed
@chargome
chargome deleted the feat/nextjs-deterministic-prerenders branch December 1, 2026 13:57
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>
chargome added a commit to getsentry/sentry-docs that referenced this pull request Dec 2, 2026
…1054)

## DESCRIBE YOUR PR

Documents the new `deterministicPrerenders` option of
`withSentryConfig`, added in getsentry/sentry-javascript#27010. It keeps
what Sentry writes into a prerendered page identical between
regenerations, for platforms that only bill an ISR write when the output
changed.

## IS YOUR CHANGE URGENT?

- [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD
- [ ] Other deadline: YYYY-MM-DD
- [x] No deadline: Not urgent, can wait up to 1 week+

## PRE-MERGE CHECKLIST

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

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.

[nextjs] Option to keep ISR output byte-identical: sentry-cache-origin / sentry-render-start change on every regeneration

2 participants