Skip to content

test(e2e): Add trace test for background use cache revalidation - #24740

Merged
s1gr1d merged 5 commits into
developfrom
sig/e2e-cache-components-revalidation
Sep 30, 2026
Merged

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

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Add a test for background stale-while-revalidate refills of use cache entries. Target behavior: the refill runs in its own trace, not as part of the trace that served the stale value. The refill trace links back to the request that triggered it and becomes the cache_origin for future hits.

The behavior is not implemented yet. The test is test.fixme(), not test.fail(): it waits for a cache.revalidate trace that never arrives, so it would hit the test timeout — and Playwright reports a timeout as a real failure even under test.fail(). Production only — the SWR timing does not hold on the dev server.

GET /api/use-cache-swr?id= — cacheLife({ stale: 5, revalidate: 2, expire: 300 }); sleep 3s after fill

Trace1 (fill)              Trace2 (stale hit)               Trace3 (hit)
|- put key:A <----link-----o get hit=true key:A             |- get hit=true key:A
                           ^                                |
                           | link (type TBD in the spec)    |
TraceR: cache.revalidate --o  (own trace)                   |
|                                                           |
|- put key:A  <----------------------link-------------------o cache_origin

Closes #24732
Linear https://linear.app/getsentry/issue/JS-3805/trace-test-for-background-use-cache-revalidation

@s1gr1d
s1gr1d requested review from chargome and cvxluo and removed request for cvxluo September 25, 2026 12:11
@github-actions

github-actions Bot commented Sep 25, 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.08 kB - -
@sentry/react (incl. Tracing) 53.54 kB - -
@sentry/vue 36.74 kB - -
@sentry/vue (incl. Tracing) 53.7 kB - -
@sentry/svelte 29.26 kB - -
CDN Bundle 31.02 kB - -
CDN Bundle (incl. Tracing) 51.77 kB - -
CDN Bundle (incl. Logs, Metrics) 33.29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.75 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74 kB - -
CDN Bundle (incl. Tracing, Replay) 89.36 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 91.33 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 95.53 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 97.5 kB - -
CDN Bundle - uncompressed 91.66 kB - -
CDN Bundle (incl. Tracing) - uncompressed 154.03 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 98.23 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 159.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.8 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 273.76 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 279.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 293.39 kB - -
@sentry/nextjs (client) 55.78 kB - -
@sentry/sveltekit (client) 51.59 kB - -
@sentry/core/server 39.99 kB - -
@sentry/core/browser 13.63 kB - -
@sentry/node 141.92 kB +0.01% +11 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.88 kB - -
@sentry/node - without tracing 90.93 kB +0.02% +11 B 🔺
@sentry/node - without channel injection 120.29 kB +0.01% +6 B 🔺
@sentry/aws-serverless 99.17 kB +0.01% +2 B 🔺
@sentry/cloudflare (withSentry) - minified 206.62 kB - -
@sentry/cloudflare (withSentry) 514.02 kB - -

View base workflow run

@chargome chargome left a comment

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.

Bit hard to follow what this actually does, tests are also failing?

import { CACHE_ORIGIN_LINK_ATTRIBUTES, findCacheSpan } from './cacheOriginLinks-utils';

// Background stale-while-revalidate refills. Target behavior: the revalidation runs in its own
// trace (not grafted onto the serving trace), links back to the request that triggered it, and

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.

grafted?

@s1gr1d

s1gr1d commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

I improved the comments a bit and also added the ASCII trace so it's easier to follow :D

@s1gr1d
s1gr1d requested a review from chargome September 28, 2026 08:31
@s1gr1d
s1gr1d merged commit bff1fba into develop Sep 30, 2026
45 checks passed
@s1gr1d
s1gr1d deleted the sig/e2e-cache-components-revalidation branch September 30, 2026 08:36
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.

trace test for background use cache revalidation

2 participants