Repository navigation
Backlog
Description
#4393 adds a core HTTP cache in packages/junior/src/chat/egress/http-cache.ts. getsentry/toolkit already has one for its CLI and MCP server. We are building the same parts twice, and compression would be one more.
What each side has
@sentry/api/client response cache (published; getsentry/toolkit uses it, and Junior already depends on @sentry/api 2.16.0):
- Freshness and revalidation through
http-cache-semantics(lookupResponse,storeResponse). - A
CacheStoreinterface (get,set,deleteMatching), a byte-budgeted memory store, identity-scoped keys (buildCacheKey) and aBodyCodectype. - Sentry-specific parts: the
classifyUrlTTL tiers andcomputeInvalidationPrefixesfor Sentry API URLs.
@sentry/toolkit-core/response-cache/codec (private to getsentry/toolkit):
- zstd level 3, with brotli when the runtime has no zstd.
- Bodies under 256 bytes stay uncompressed.
- Decompression never goes past the recorded size.
Junior's HTTP cache:
- Keys by credential scope and request, and saves entries in the Redis state adapter for 6 h.
- TTLs come from the link type or plugin.
staleIfErrorserves the last entry on errors, 429 and 5xx.onStalegives cards theirfetchedAt.- Bodies are plain JSON strings, up to 256 KiB. Junior has its own zstd code in
chat/cache-warming/snapshot.ts.
Decided
- The shared library is a new package, not part of
@sentry/apior toolkit-core. - The plugin TTL wins over server cache headers. Server headers can only shorten freshness, never extend it. For example, GitHub card reads use TTL 0 and depend on webhooks, so a server
max-agemust not make them skip revalidation.
Plan
- Create the new package from the provider-neutral parts of the
@sentry/api/clientresponse cache: the policy,CacheStore, the memory store and identity-scoped keys. TTL tiers and invalidation prefixes become options, and Sentry's are a preset. - Add stale-if-error and an
onStalesignal. Add the TTL rule above, so a caller's TTL caps the freshness that server headers give. - Move the toolkit body codec into the new package.
- Move getsentry/toolkit onto the new package.
- Move Junior's
chat/egress/http-cache.tsonto it, as aCacheStoreover the state adapter that is keyed by credential scope. Plugin TTLs and GitHub webhook invalidation stay in Junior. - Store bodies compressed, which saves Redis memory. State values are JSON, so compressed bytes are stored as base64, the same way cache-warming snapshots are. The 256 KiB body limit can then apply to the stored size.
via @BYK.
--
Metadata
Metadata
Assignees
Labels
No labels
Activity
feat(http): Add withRetry, and move CLI and MCP retries onto it