Skip to content

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

Merged
mydea merged 10 commits into
developfrom
feat/nuxt-nitro-v3-cache-instrumentation
Nov 13, 2026
Merged

mydea merged 10 commits into
developfrom
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]

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: cc59724 (PR test merge using develop at 60f2958)

Against: 60f2958 (develop) · base run #65933

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.04 kB - -
@sentry/browser - with treeshaking flags 28.23 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.12 kB - -
@sentry/browser (incl. Tracing) 52.2 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.2 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.17 kB - -
@sentry/browser (incl. Tracing, Replay) 92.73 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.52 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.08 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.51 kB - -
@sentry/browser (incl. Feedback) 47.66 kB - -
@sentry/browser (incl. sendFeedback) 30.62 kB - -
@sentry/browser (incl. FeedbackAsync) 35.62 kB - -
@sentry/browser (incl. Metrics) 31.36 kB - -
@sentry/browser (incl. Logs) 31.64 kB - -
@sentry/browser (incl. Metrics & Logs) 32.3 kB - -
@sentry/react 32.04 kB - -
@sentry/react (incl. Tracing) 54.86 kB - -
@sentry/vue 38.21 kB - -
@sentry/vue (incl. Tracing) 55.14 kB - -
@sentry/svelte 30.05 kB - -
@sentry/remix (Remix 3 client bundle) 57.96 kB - -
CDN Bundle 31.79 kB - -
CDN Bundle (incl. Tracing) 52.58 kB - -
CDN Bundle (incl. Logs, Metrics) 34.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.14 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.61 kB - -
CDN Bundle (incl. Tracing, Replay) 90.63 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.25 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.6 kB - -
CDN Bundle - uncompressed 92.69 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.13 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 101.03 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 162.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.11 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.27 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 282.9 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 287.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 294.69 kB - -
@sentry/nextjs (client) 58.23 kB - -
@sentry/sveltekit (client) 53.26 kB - -
@sentry/core/server 44.53 kB - -
@sentry/core/browser 13.99 kB - -
@sentry/node 149.49 kB -0.01% -4 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.3 kB - -
@sentry/node - without tracing 88.39 kB -0.01% -6 B 🔽
@sentry/node - without channel injection 138.45 kB -0.01% -2 B 🔽
@sentry/aws-serverless 97.3 kB -0.01% -7 B 🔽
@sentry/cloudflare (withSentry) - minified 204.35 kB - -
@sentry/cloudflare (withSentry) 474.32 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 229.66 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. 7 successful. See the run.

Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (tunnel-dev) Test (optional) Successful in 1m Details

@mydea
mydea added this pull request to stack #26016 November 3, 2026 10:56
@mydea mydea self-assigned this Nov 3, 2026
@mydea
mydea force-pushed the feat/nuxt-nitro-v3-cache-instrumentation branch from 9a64d17 to 0d9ba54 Compare November 3, 2026 11:55
Base automatically changed from fix/nuxt-5-nitro-rc to develop November 4, 2026 09:51
@mydea
mydea force-pushed the feat/nuxt-nitro-v3-cache-instrumentation branch from 2222437 to b919c0d Compare November 4, 2026 12:18
@mydea
mydea marked this pull request as ready for review November 4, 2026 13:44
@mydea
mydea requested review from a team as code owners November 4, 2026 13:44
@mydea
mydea requested review from Lms24, andreiborza, chargome, logaretm, mydea and s1gr1d and removed request for a team November 4, 2026 13:44

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b919c0d. Configure here.

@logaretm logaretm 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.

I think the approach is a bit risky since it matches user code. I know we have precedents for that.

But I think I can PR tracing channels to ocache upstream since Nitro's ecosystem doesn't mind it.

@mydea

mydea commented Nov 11, 2026

Copy link
Copy Markdown
Member

I think the approach is a bit risky since it matches user code. I know we have precedents for that.But I think I can PR tracing channels to ocache upstream since Nitro's ecosystem doesn't mind it.

yeah that would be nicer! should we still merge this like this or would you prefer to postpone this/do this differently for now @logaretm ?

Copy link
Copy Markdown
Member

let's merge it, i think the tracing channel solution will take sometime to get merged, and when it does we can rip this one out as long as nitro remains in rc.

sentry-junior Bot and others added 10 commits November 13, 2026 08:59
…se the deployment is missing a file (#26272)

**Why:** Follow-up to #26271. When `Module.register()` fails with
`ERR_MODULE_NOT_FOUND`, the always-on warning used to just repeat Node's
"Cannot find module …". That reads like an SDK bug, when the real cause
is that a build tracer didn't ship all of
`@sentry/server-runtime-injection`. The warning now says so. I checked
on Node 22 that `error.code` survives the trip back from the loader
thread. The warning still fires once per process: issue #26121 asks for
it to be quiet, but staying silent would hide that channel integrations
aren't recording anything (see #25677).

**How to review:** It's a single branch in the `catch` block of
`registerDiagnosticsChannelInjection()`, plus one unit test.

Refs #26121

<!-- junior-request-attribution:start -->
via **Francesco Gringl-Novy**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AD0CA8FXFXAS%3A1794383205.954799 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AD0CA8FXFXAS%3A1794383205.954799)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0CA8FXFXAS%3A1794383205.954799/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Francesco Gringl-Novy <francesco.novy@sentry.io>
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>
@mydea
mydea force-pushed the feat/nuxt-nitro-v3-cache-instrumentation branch from 2b9a192 to 9414e89 Compare November 13, 2026 07:59
@mydea
mydea requested a review from a team November 13, 2026 07:59
@mydea
mydea merged commit a72b2d8 into develop Nov 13, 2026
74 checks passed
@mydea
mydea deleted the feat/nuxt-nitro-v3-cache-instrumentation branch November 13, 2026 09:45
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