Repository navigation
feat(mcp-cloudflare): Share allowlisted cache entries across isolates through R2 - #1842
Open
sentry-junior[bot] wants to merge 2 commits into
Open
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
sentry-junior
Bot
force-pushed
the
feat/hosted-response-cache-r2
branch
from
November 12, 2026 21:21
ef73346 to
1c80bb7
Compare
Contributor
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 1c80bb7. Configure here.
… through R2 Add the R2 tier of the hosted response cache behind MCP_RESPONSE_CACHE=tiered. TieredStore reads memory, then R2, for organization event details (without averageColumn) and project trace-item details (without debug). It writes to R2 only when the response carries Cache-Control: private with a positive max-age, and expires objects at the lesser of max-age and 5 minutes, checked on read. Writes run in waitUntil, and a 1-day bucket lifecycle rule collects garbage. The shared cache policy in @sentry/api/client keeps only Link in entry headers, so R2 eligibility reads Cache-Control from the response headers in the entry's serialized http-cache-semantics policy. Authorization values kept for Vary matching are stored as SHA-256 hashes, never as tokens. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…he entries The local hashAuthorization only matched a lowercase authorization key, so an Authorization header in any other casing would have reached the policy as given. @sentry/api's storeResponse and lookupResponse already hash every header named Authorization, whatever its casing, so drop the local copy and test that R2 never holds the token under mixed-case headers.
sentry-junior
Bot
force-pushed
the
feat/hosted-response-cache-r2
branch
from
November 12, 2026 21:55
1c80bb7 to
5e1e814
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Task 7.3 of the #1669 plan. It is stacked on #1833 (7.1) and adds the R2 tier behind
MCP_RESPONSE_CACHE=tiered. Merge #1833 first, and only after the buckets below exist.Still off everywhere. No config sets
MCP_RESPONSE_CACHE, so the new binding is inert in every deployed environment. Whentieredhas no bucket, it logs one warning and caches in memory only.What goes to R2 (
src/server/lib/r2-cache-store.ts):/api/0/organizations/{org}/events/{project}:{event_id}/withoutaverageColumn, and/api/0/projects/{org}/{project}/trace-items/{id}/withoutdebug. Every other URL uses the memory store unchanged.Cache-Control: privatewith a positivemax-age, and nono-storeorno-cache. Until feat(api): Add opt-in max-age mode to ConditionalGetResponseMixin sentry#128828 ships, R2 stores nothing.expiresAt=createdAt+ min(max-age, 5 min) in custom metadata, and reads enforce it. An R2 hit is copied into memory only for the time it has left. A 1-day lifecycle rule is only garbage collection.waitUntil. Invalidation touches memory only, as in the design. A write under the same path, such as deleting a project, does not clear R2 within the 5-minute window. This is part of the 7.4 sign-off.Identity isolation. Object keys are
<grant identity>/<HMAC cache key>, and a read also rejects an entry whose stored identity differs.Vary: Authorizationmakes the policy keep request headers, so the cache now storessha256:of the Authorization value, never the raw upstream token. That applies to memory too.Where
Cache-Controlcomes from.@sentry/api's cache policy keeps onlyLinkin entry headers, so R2 eligibility readsCache-Controlfrom the response headers in the entry's serializedhttp-cache-semanticspolicy. A test stores a real response throughstoreResponseand fails if thatCache-Controlis lost.Tests (workerd, real miniflare R2 bucket):
max-age=0. In those cases the entry stays memory-only.averageColumn,debug) are memory only.max-age=3600is capped at 5 minutes, andmax-age=60expires at 60 s.Cache-Controlfrom entry headers instead of the policy fails 9 tests.Metrics (7.5):
app.response_cache.r2.lookup(hit/miss/expired) andapp.response_cache.r2.write, plus warning logs for R2 failures. Both are documented indocs/operations/monitoring.md.Provisioning (required before merge). Deploys use
--experimental-auto-create=false, so a Cloudflare admin must run:I created nothing. The same steps are in
docs/cloudflare/architecture.md.Pending, needs a deployed Worker: 7.2 (zstd) and the 7.5 preview check, as described in #1833. With
tieredon a preview, also check thatr2.lookupshows up.r2.writestays at zero until the server headers ship. 7.4 is a human privacy/security sign-off.Checks (after rebasing onto #1833's merge of
main):pnpm run tsc,pnpm run lint, anddocs:checkpass. Tests pass for toolkit-core (138) and mcp-cloudflare (509). In mcp-core, 2281 tests passed and 6 were skipped. Fivesearch-eventstimeseries tests timed out at 5 s in the full run, then all 97 tests in that file passed on their own. This PR doesn't change mcp-core.via @BYK.
--
View Session [Sentry]