Repository navigation
feat(nuxt): Instrument Nitro v3 cache storage - #25951
Conversation
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.
|
Optional E2E testsAll optional checks were successful. 7 successful. See the run. Successful checks
|
9a64d17 to
0d9ba54
Compare
2222437 to
b919c0d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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
left a comment
There was a problem hiding this comment.
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 ? |
|
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. |
…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>
2b9a192 to
9414e89
Compare

Why: Starting with the RC, Nitro v3 runs
defineCachedFunction/defineCachedHandler(andcacheroute rules) on anocachestorage. That storage only goes through KV storage when thekvcache driver is set, so with the defaultmemorydriver (and withfs) our KV driver instrumentation never sees cache reads or writes, and nocache.*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/cachemodule, though, so a bundler transform wraps that module'screateCacheStorageexport and the storage gets patched in place. It has to be patched in place becauseocachealso readsbinaryandmaxEntryBytesfrom the storage object. Thekvdriver is skipped because the existing KV instrumentation already covers it.cache.hitcomes from the stored entry: it must have a value, be unexpired, and not be markedstale. This PR also undoes thekvworkaround in the nuxt-5 E2E app, so the default driver is what gets tested.How to review: Start with
cacheStorageInstrumentationPlugininvite/storageConfig.ts, theninstrumentCacheStorageinruntime/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]