Repository navigation
feat(sveltekit): Mark pageloads of prerendered pages - #26307
Conversation
|
bugbot run |
| return getTraceMetaTags(); | ||
| } | ||
| return isServerRenderedPage(html) ? `<meta name="${CACHE_ORIGIN_META_TAG_NAME}" content=""/>` : ''; | ||
| return isServerRenderedPage(html) ? `<meta name="${CACHE_ORIGIN_META_TAG_NAME}" content="${cacheOrigin}"/>` : ''; |
There was a problem hiding this comment.
what does a '' cache origin mean? 🤔 I wonder if we can simplify this a bit, I always find it a bit hard to follow if something can deliberately return '' or undefined 🤔
There was a problem hiding this comment.
Good point. The empty value means "the page was rendered earlier, but we cannot link to it" (e.g. because it happened during build time). I'm gonna make that more clear.
…el-isr # Conflicts: # CHANGELOG.md # dev-packages/e2e-tests/test-applications/sveltekit-2-static/tests/sdk.test.ts # dev-packages/e2e-tests/test-applications/sveltekit-3/tests/prerender.test.ts # packages/sveltekit/src/client/svelte4BrowserTracing.ts # packages/sveltekit/src/client/svelte5BrowserTracing.ts # packages/sveltekit/src/client/traceMetaTags.ts # packages/sveltekit/src/common/traceMetaTags.ts # packages/sveltekit/src/server-common/handle.ts # packages/sveltekit/test/client/browserTracingIntegration.test.ts # packages/sveltekit/test/client/svelte5BrowserTracing.test.ts
size-limit report 📦Compared: 1f5a46f (PR test merge using develop at 88cc648) Against: 88cc648 (develop) · base run #66002 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 4 not successful, 45 successful. See the run.
Successful checks
|
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e91fb79. Configure here.
| pageloadSpanPromise, | ||
| ]); | ||
|
|
||
| expect(originSpan.trace_id).toBe(originTraceId); |
There was a problem hiding this comment.
Could we additionally check that expect(getSpanOp(originSpan)).toBe('http.server') here? SInce we do not control the spans from sveltekit this would verify that actually attach it to the segment/root span
With Kit tracing, the active span during the render is Kit's `sveltekit.resolve`, so the cache origin pointed at it instead of the request's root span. Also removes an unrelated `@pnpm/exe` lockfile entry.
Stacked on #26301.
Why: Vercel ISR (
config.isr) caches the HTML of one request and serves it to every visitor until it expires. That HTML holds the livesentry-traceandbaggagetags of the render, so every visitor continued the same old server trace. Next.js had the same bug, fixed in #25141. Now a page that Vercel renders for its ISR cache gets asentry-cache-origintag with the render'ssentry-tracein place of the trace tags. The pageload starts its own trace, getspage.server_rendering.type: static, and links the render with acache_originlink, as in Next.js (#25318).To detect an ISR render,
sentryHandlereads thex-vercel-isrrequest header. Vercel sends it to every invocation of an ISR function, also for background revalidations and for routes that getconfig.isrfrom a layout. The adapter's own__pathnamemarker is gone before Kit sees the request, andhandlecannot see the route config (tested both on a Vercel deployment).Like a
use cachehit, the pageload links only a sampled render. An unsampled render still marks the pageload asstatic. A page withssr = falsegets no tags, as in the build.How to review: Start with
getCacheOrigininhandle.ts. It returns the render's trace (ISR),''(build) orundefined(rendered for this request only). ThenwithCacheOrigininclient/traceMetaTags.ts. The two browser-tracing variants only wrap their existing span options.Unsure about: A client can send
x-vercel-isrto a normal SSR route, and the function sees it. That only changes the pageload of the request that sends it: it links its own server request instead of continuing it. I think that is acceptable. I did not check draft mode (bypassToken), where Vercel does not cache the render.Example with the UI changes from getsentry/sentry#130771 (a visitor that got an already happened ISR render):

https://sentry-4x3dkn58u.sentry.dev/explore/traces/trace/63b1dbe5fe3849f2b13df81530857c03/
Linear: JSSDK-37