Skip to content

test(nextjs): Add E2E assertions for use cache functions - #24301

Merged
s1gr1d merged 2 commits into
developfrom
sig/nextjs-use-cache-tests
Sep 11, 2026
Merged

test(nextjs): Add E2E assertions for use cache functions#24301
s1gr1d merged 2 commits into
developfrom
sig/nextjs-use-cache-tests

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 10, 2026

Copy link
Copy Markdown
Member

Part of this issue: #24289
and also the E2E tests: #24290

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.91 kB - -
@sentry/browser - with treeshaking flags 27.21 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.1 kB - -
@sentry/browser (incl. Tracing) 50.27 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.28 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.26 kB - -
@sentry/browser (incl. Tracing, Replay) 89.76 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 78.86 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.45 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.46 kB - -
@sentry/browser (incl. Feedback) 46.4 kB - -
@sentry/browser (incl. sendFeedback) 33.96 kB - -
@sentry/browser (incl. FeedbackAsync) 39.07 kB - -
@sentry/browser (incl. Metrics) 29.93 kB - -
@sentry/browser (incl. Logs) 30.19 kB - -
@sentry/browser (incl. Metrics & Logs) 30.86 kB - -
@sentry/react 30.66 kB - -
@sentry/react (incl. Tracing) 52.59 kB - -
@sentry/vue 36.15 kB - -
@sentry/vue (incl. Tracing) 52.53 kB - -
@sentry/svelte 28.93 kB - -
CDN Bundle 30.64 kB - -
CDN Bundle (incl. Tracing) 50.78 kB - -
CDN Bundle (incl. Logs, Metrics) 32.92 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 52.73 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.61 kB - -
CDN Bundle (incl. Tracing, Replay) 88.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.29 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.36 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.38 kB - -
CDN Bundle - uncompressed 90.72 kB - -
CDN Bundle (incl. Tracing) - uncompressed 151.68 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.3 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 157.64 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.71 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 271.25 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 277.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 284.95 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 290.89 kB - -
@sentry/nextjs (client) 54.91 kB - -
@sentry/sveltekit (client) 50.69 kB - -
@sentry/core/server 37.1 kB - -
@sentry/core/browser 13.66 kB - -
@sentry/node 128.46 kB +0.02% +20 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.82 kB - -
@sentry/node - without tracing 89.04 kB +0.03% +25 B 🔺
@sentry/node - without channel injection 107.54 kB +0.03% +22 B 🔺
@sentry/aws-serverless 97.43 kB +0.03% +22 B 🔺
@sentry/cloudflare (withSentry) - minified 203.1 kB - -
@sentry/cloudflare (withSentry) 505.66 kB - -

View base workflow run

Comment on lines +105 to +107
// The dev server serves `use cache` entries past their `expire` limit, so the expiry path only
// exists in production builds.
test.skip(process.env.TEST_ENV !== 'production', 'Entries only hard-expire in production');

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.

q: What does this mean exactly for dev then?

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.

In dev, entries aren't discarded when their expire time passes. next dev keeps a use cache entry for at least 5 minutes (MIN_PRERENDERABLE_EXPIRE), even when its expire is shorter.

I'm gonna make that more clear in the comment (but I'll add it in the other PR to avoid conflicts).

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.

Done in this commit:
acf0483 (#24302)

@s1gr1d
s1gr1d merged commit 357b211 into develop Sep 11, 2026
44 checks passed
@s1gr1d
s1gr1d deleted the sig/nextjs-use-cache-tests branch September 11, 2026 12:21
s1gr1d added a commit that referenced this pull request Sep 11, 2026
First merge: #24301


`use cache` reads and writes are invisible in traces. This wraps
`get`/`set` on Next's cache-handler registry
(`@next/cache-handlers-map`, plus the dev-only private handler) with
`cache.get`/`cache.put` spans.

Decisions:

- Keys are SHA-1 digests, because raw keys serialize function arguments
(PII).
- `cache.hit` mirrors Next: entries past `expire` count as misses. Tag
discards stay hits (undetectable at the handler).
- Hits carry `cache.item_age`, `cache.ttl`, and `cache.tags`. The first
and last are pending sentry-conventions upstreaming.
- Guards live on `globalThis` (the module loads once per bundle). Both
initorderings work: `next start` and dev server.

Related to #12888.
But the legacy incremental cache (fetch/ISR) stays uncovered.

**Cache Fill**
<img width="813" height="282" alt="image"
src="https://github.com/user-attachments/assets/bd1a5e84-4c7c-40a5-9651-8670f6ff3726"
/>

--- 
**Cache Get**
<img width="805" height="135" alt="image"
src="https://github.com/user-attachments/assets/875ba0c1-f222-4f26-a6bd-7b545101067e"
/>



Closes #24289
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