Skip to content

test(e2e): Add Next.js cache component nesting scenarios - #24704

Merged
s1gr1d merged 5 commits into
developfrom
sig/nextjs-cache-components-e2e-nesting
Sep 25, 2026
Merged

s1gr1d merged 5 commits into
developfrom
sig/nextjs-cache-components-e2e-nesting

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 24, 2026

Copy link
Copy Markdown
Member

Add tests for 4 different nested cache component scenarios. Currently all in a "failed" state as this is not yet implemented.

Legend
  T1, T2, T3   traces, one per request, in order
  ck:X         cache.key digest of entry X
  o--> put     span link (sentry.link.type: 'cache_origin'), target = the cache.put span

1. Cached layout in the middle

app/(cached-nesting)/cached-mid-layout/
  [id]/layout.tsx     'use cache' (hours), key <- awaited [id]
  [id]/page.tsx       dynamic (awaits headers)

Request 1 (fill)                        Request 2 (hit)
T1: GET /cached-mid-layout/[id]         T2: GET /cached-mid-layout/[id]
 |- cache.get  hit=false  ck:layout      |- cache.get  hit=true  ck:layout
 |- cache.put  ck:layout  <-----------------o cache_origin
 |- dynamic page render                  |- dynamic page render (no cache spans)

2. Dynamic Layouts, Cached Leaf

app/(cached-nesting)/dynamic-layouts/
  [id]/layout.tsx                       dynamic (awaits headers)
  [id]/layout-cached-leaf/page.tsx      page renders CachedLeaf ('use cache', hours)

Request 1 (fill)                        Request 2 (hit)
T1: GET /dynamic-layouts/[id]/...       T2: GET /dynamic-layouts/[id]/...
 |- cache.put  ck:leaf  <-------------------o cache.get  hit=true  ck:leaf

3. Mixed lifetimes: two cache links, but pointing to a different origin

app/(cached-nesting)/mixed-lifetimes/
  [id]/layout.tsx     'use cache', expire: 2s   <- short-lived
  [id]/page.tsx       dynamic + LongLivedComponent ('use cache', hours)

T1 (fill both)          --sleep 3s-->   T2 (layout expired)        T3 (both hit)
 |- put ck:layout                        |- get hit=false ck:layout |- get hit=true ck:layout
 |- put ck:cmp                           |- put ck:layout  <------------o cache_origin
      ^                                  |- get hit=true  ck:cmp    |- get hit=true ck:cmp
      |                                                                  |
      +---------------------------------------------------------------o cache_origin

4. Shared layout across sibling routes: Origin trace is different than serving (/a and /b)

app/(cached-nesting)/shared-layout/
  [id]/layout.tsx     'use cache' (hours) — ONE entry shared by a and b
  [id]/a/page.tsx     dynamic
  [id]/b/page.tsx     dynamic

Request 1: /shared-layout/<id>/a        Request 2: /shared-layout/<id>/b
T1: GET /shared-layout/[id]/a           T2: GET /shared-layout/[id]/b
 |- cache.put  ck:layout  <-----------------o cache.get  hit=true  ck:layout

Closes #24701

@s1gr1d
s1gr1d requested a review from chargome September 24, 2026 14:16

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.

From here, all is same-same, but just with span streaming

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.24 kB - -
@sentry/browser - with treeshaking flags 27.5 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.4 kB - -
@sentry/browser (incl. Tracing) 51.15 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.17 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.18 kB - -
@sentry/browser (incl. Tracing, Replay) 90.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 95.46 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 108.41 kB - -
@sentry/browser (incl. Feedback) 46.76 kB - -
@sentry/browser (incl. sendFeedback) 34.3 kB - -
@sentry/browser (incl. FeedbackAsync) 39.41 kB - -
@sentry/browser (incl. Metrics) 30.25 kB - -
@sentry/browser (incl. Logs) 30.51 kB - -
@sentry/browser (incl. Metrics & Logs) 31.18 kB - -
@sentry/react 31 kB - -
@sentry/react (incl. Tracing) 53.45 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 30.93 kB - -
CDN Bundle (incl. Tracing) 51.69 kB - -
CDN Bundle (incl. Logs, Metrics) 33.2 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.66 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.92 kB - -
CDN Bundle (incl. Tracing, Replay) 89.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.45 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.42 kB - -
CDN Bundle - uncompressed 91.4 kB - -
CDN Bundle (incl. Tracing) - uncompressed 153.77 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.97 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.54 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.5 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.13 kB - -
@sentry/nextjs (client) 55.77 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.95 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 133.9 kB +0.01% +7 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.43 kB - -
@sentry/node - without tracing 90.46 kB +0.02% +15 B 🔺
@sentry/node - without channel injection 112.42 kB +0.02% +12 B 🔺
@sentry/aws-serverless 98.72 kB +0.01% +4 B 🔺
@sentry/cloudflare (withSentry) - minified 206.49 kB - -
@sentry/cloudflare (withSentry) 513.73 kB - -

View base workflow run

@s1gr1d
s1gr1d merged commit 0f34ffb into develop Sep 25, 2026
325 of 326 checks passed
@s1gr1d
s1gr1d deleted the sig/nextjs-cache-components-e2e-nesting branch September 25, 2026 11:16
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.

E2E tests for nested caches

2 participants