Repository navigation
feat(nuxt): Mark pageloads of cached pages - #26305
Conversation
size-limit report 📦Compared: cd811a3 (PR test merge using develop at a72b2d8) Against: a72b2d8 (develop) · base run #65953 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 6 not successful, 54 successful. See the run.
Successful checks
|
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b7f3888. Configure here.
h3 v1 (1.8+) and h3 v2 both have event.headers with the request's web Headers. Read the x-nitro-prerender header from it, in place of the cast to a per-version event shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| // The Nitro prerenderer sends this header with each route it renders (Nitro v2 and v3). `event.headers` | ||
| // exists in h3 v1 (1.8+) and h3 v2, where it is a deprecated alias of `event.req.headers`. | ||
| function isPrerenderRequest(event: H3Event): boolean { | ||
| return event.headers.has('x-nitro-prerender'); |
There was a problem hiding this comment.
Regarding your comment on this function, should be be more conservative here?
| return event.headers.has('x-nitro-prerender'); | |
| return !!event.headers?.has?.('x-nitro-prerender'); |
There was a problem hiding this comment.
Should we test on nuxt-5 too already?
…aders h3 v2 deprecates event.headers. If a later h3 removes it, the page now gets the live trace tags, and render:html does not throw.
Use the nuxt-4 cached-HTML checks on nuxt-5 (Nitro v3) and enable the SWR tests again. Add vue-router, which the current nuxt-nightly@5x needs.
…26363) ## What Next.js, Nuxt and SvelteKit now use one shared implementation of the `sentry-cache-origin` tag from #25318, #26305 and #26307. There is no change for users. - `@sentry/core` holds the tag name, the server code that writes the tag, and the client code that marks and links the pageload. All of these are `_INTERNAL_` exports. The client part is in `@sentry/core/browser`, and the server part is in `@sentry/core/server`. - Nuxt now links the request's root span explicitly, like SvelteKit. The Nuxt E2E tests check that the tag holds the `http.server` root span. ## Why Each SDK had its own copy of the tag name, the tag writer and the pageload logic. With one module, the server writer and the client reader cannot drift apart. A round-trip test now checks that the client reads the tag the server writes. Each framework keeps its own decision about which page is reused (build, `x-vercel-isr`, Nitro route rules, Next.js prerender context). Those rules differ per framework, so a shared helper would only pass them through. The Nuxt change already behaves the same today: no child span is active while Nuxt renders the page. The explicit root span protects the link from a future child span. That is the bug SvelteKit had with `sveltekit.resolve`. Two edge cases are now handled the same way in all three SDKs, and the SDKs never write either one: - An empty tag marks the pageload without a link. Before this change, only Next.js ignored an empty tag, and Next.js never writes one. - Core reads the first tag. Before this change, Next.js read the last one, but a Next.js document never has more than one tag.

Why: Visitors of a Nuxt page cached by a route rule (
cache,swr,isron Vercel/Netlify) continued the server trace of the request that rendered it. Like Next.js (#25318) and SvelteKit (#26301), these pages now get asentry-cache-originmeta tag in place of the trace tags. The pageload isstaticand links the render if it was sampled.isronly counts as cached on presets with a platform cache: onnode-server, Nitro rendersisrpages per request. Tested on a Vercel deploy.How to review: Start with
runtime/utils/pageMetaTags.ts(server decision) andruntime/utils/cacheOriginPageload.ts(pageload).Unsure about:
withCacheOriginnow exists in Next.js, SvelteKit and Nuxt. I plan to share it from@sentry/browserin a follow-up.Example with the UI changes from getsentry/sentry#130771

https://sentry-4x3dkn58u.sentry.dev/explore/traces/trace/e7492219ab72481989d6a2cd670fe8d9/
Linear: JSSDK-36