feat(nextjs): Add code.file.path to use cache fill spans - #24988
Conversation
|
|
||
| fill(handler, 'set', (originalSet: UseCacheHandler['set']) => { | ||
| return function (this: UseCacheHandler, cacheKey: string, pendingEntry: Promise<unknown>): Promise<void> { | ||
| const digest = keyDigest(cacheKey); |
There was a problem hiding this comment.
m: Can we gate this with shouldRecordCacheSpan again?
There was a problem hiding this comment.
ah sure! seems like the conflicts merge got it wrong
|
bugbot run |
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b2703e7. Configure here.
| return startCacheSpan(CACHE_PUT, digest, span => { | ||
| if (sourceFile) { | ||
| span.setAttribute(CODE_FILE_PATH, sourceFile); | ||
| } |
There was a problem hiding this comment.
Span attribute set after start
Medium Severity
sourceFile is already resolved before startCacheSpan runs, but code.file.path is attached afterward with span.setAttribute. tracesSampler and ignoreSpans only see attributes passed into startSpan, so they cannot filter these cache fill spans by source file.
Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit b2703e7. Configure here.


Adds
code.file.pathtocache.putspans, souse cachespans show which function they belong to.The cache key contains the function id. Next.js' server-reference manifest maps it to the source file. Keys come in two forms:
["buildId","c0a941ad…",[args]](start with[)params,children):1:069:["buildId","c0a941ad…",[…]]1:1c:{"id":"123"}(length-prefixed fields)Logged real-world data to use this in the unit tests (from 16.3 and canary version).
Linear: https://linear.app/getsentry/issue/JSSDK-31/add-cache-source-file-to-trace-back-where-the-cache-was-created