Skip to content

feat(nuxt): Instrument Nitro v3 cache storage - #25951

Draft
sentry-junior[bot] wants to merge 2 commits into
fix/nuxt-5-nitro-rcfrom
feat/nuxt-nitro-v3-cache-instrumentation
Draft

sentry-junior[bot] wants to merge 2 commits into
fix/nuxt-5-nitro-rcfrom
feat/nuxt-nitro-v3-cache-instrumentation

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Why: Starting with the RC, Nitro v3 runs defineCachedFunction / defineCachedHandler (and cache route rules) on an ocache storage. That storage only goes through KV storage when the kv cache driver is set, so with the default memory driver (and with fs) our KV driver instrumentation never sees cache reads or writes, and no cache.* spans are produced. Nitro doesn't offer a tracing channel for its cache, and the storage instance is private to Nitro's runtime. It is created in the build-time #nitro/virtual/cache module, though, so a bundler transform wraps that module's createCacheStorage export and the storage gets patched in place. It has to be patched in place because ocache also reads binary and maxEntryBytes from the storage object. The kv driver is skipped because the existing KV instrumentation already covers it. cache.hit comes from the stored entry: it must have a value, be unexpired, and not be marked stale. This PR also undoes the kv workaround in the nuxt-5 E2E app, so the default driver is what gets tested.

How to review: Start with cacheStorageInstrumentationPlugin in vite/storageConfig.ts, then instrumentCacheStorage in runtime/utils/instrumentStorage.ts. The span wrapper is now shared with the KV driver instrumentation, and KV behavior is unchanged.

Unsure about: The transform matches the exact export const createCacheStorage = line that Nitro generates. If Nitro changes that template, the transform does nothing (no crash), but cache spans would disappear again. Is that acceptable, or should we push upstream for a tracing channel or hook in Nitro/ocache? Note this is stacked on #25949.

via Francesco Gringl-Novy.

--

View Session [Sentry]

Nitro v3 keeps cached functions and handlers in an ocache storage that
only goes through KV storage with the `kv` cache driver, so the default
`memory` and the `fs` drivers produced no cache spans. Wrap the
storage that the `#nitro/virtual/cache` module creates at build time.

Co-Authored-By: Francesco Gringl-Novy <francesco.novy@sentry.io>
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 6ac1b5c (PR test merge using fix/nuxt-5-nitro-rc at 24d8402)

Against: 7aca628 (fix/nuxt-5-nitro-rc) · base run #64423

⚠️ Baseline mismatch: 1 fix/nuxt-5-nitro-rc commit(s) in the PR build are missing from the baseline. Their size changes also affect this comparison. Compare commits. Re-run once fix/nuxt-5-nitro-rc's baseline build for 24d8402 finishes.

Path Size % Change Change
@sentry/browser 30.39 kB - -
@sentry/browser - with treeshaking flags 28.53 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.42 kB - -
@sentry/browser (incl. Tracing) 52.7 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.71 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.68 kB - -
@sentry/browser (incl. Tracing, Replay) 93.01 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.6 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.75 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.74 kB - -
@sentry/browser (incl. Feedback) 47.97 kB - -
@sentry/browser (incl. sendFeedback) 35.49 kB - -
@sentry/browser (incl. FeedbackAsync) 40.6 kB - -
@sentry/browser (incl. Metrics) 31.42 kB - -
@sentry/browser (incl. Logs) 31.72 kB - -
@sentry/browser (incl. Metrics & Logs) 32.44 kB - -
@sentry/react 32.27 kB - -
@sentry/react (incl. Tracing) 55.07 kB - -
@sentry/vue 38.66 kB - -
@sentry/vue (incl. Tracing) 55.72 kB - -
@sentry/svelte 30.42 kB - -
@sentry/remix (Remix 3 client bundle) 57.79 kB - -
CDN Bundle 32.18 kB - -
CDN Bundle (incl. Tracing) 53.23 kB - -
CDN Bundle (incl. Logs, Metrics) 34.45 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.17 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.86 kB - -
CDN Bundle (incl. Tracing, Replay) 91.44 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.38 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.56 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.55 kB - -
CDN Bundle - uncompressed 94.62 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.58 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.09 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.31 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.65 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 279.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 284.99 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 298.69 kB - -
@sentry/nextjs (client) 57.87 kB - -
@sentry/sveltekit (client) 53.22 kB - -
@sentry/core/server 44.24 kB - -
@sentry/core/browser 13.93 kB - -
@sentry/node 154.95 kB +0.02% +19 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.08 kB - -
@sentry/node - without tracing 96.23 kB +0.03% +21 B 🔺
@sentry/node - without channel injection 135.33 kB +0.01% +13 B 🔺
@sentry/aws-serverless 104.42 kB +0.03% +27 B 🔺
@sentry/cloudflare (withSentry) - minified 197.91 kB - -
@sentry/cloudflare (withSentry) 491.89 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 218.34 kB - -

View base workflow run

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

All optional checks were successful. 4 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 32s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 22s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 23s Details

This branch has not been deployed

No deployments
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.

0 participants