Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/sveltekit
SDK Version
11.6.0
Framework Version
@sveltejs/kit 3.0.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
// vite.config.ts
import { sentrySvelteKit } from '@sentry/sveltekit/vite';
sentrySvelteKit({ autoInstrument: { load: true, serverLoad: true } });
Steps to Reproduce
- Add a
+layout.server.ts load that doesn't read url, so SvelteKit only reruns it when one of its own dependencies changes.
- Enable load auto-instrumentation (or wrap the load with
wrapServerLoadWithSentry).
- Navigate between two pages under that layout.
Minimal check without an app, which is what we run in our tests:
import { wrapServerLoadWithSentry } from '@sentry/sveltekit';
const reads: string[] = [];
let tracking = true;
const url = new Proxy(new URL('https://example.com/a'), {
get(target, prop) {
if (tracking && typeof prop === 'string') reads.push(prop);
const value = Reflect.get(target, prop);
return typeof value === 'function' ? value.bind(target) : value;
},
});
const untrack = <T>(fn: () => T) => {
tracking = false;
try {
return fn();
} finally {
tracking = true;
}
};
await wrapServerLoadWithSentry(() => ({}))({
url,
untrack,
route: { id: '/a' },
request: { method: 'GET' },
} as never);
console.log(reads); // [ 'pathname' ]
Expected Result
The wrapper doesn't add a URL dependency to the load. Like 10.x, where event.url.pathname was only read as a fallback span name when there's no route id.
Actual Result
The layout load reruns on every navigation. The url.path attribute added in #24341 reads event.url.pathname outside untrack in wrapLoadWithSentry (client and server) and wrapServerLoadWithSentry, so SvelteKit marks every wrapped load as depending on the pathname. With auto-instrumentation on, that's every load in the app, including root layouts that fetch session data.
Additional Context
getRouteId already reads event.route.id through event.untrack for exactly this reason. Reading the pathname the same way fixes it. We're carrying this as a patch on 11.6.0:
const pathname = typeof event.untrack === 'function'
? event.untrack(() => event.url.pathname)
: event.url.pathname;
const routeOrPathname = routeId ? routeId : pathname;
// ...
[URL_PATH]: pathname,
Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/sveltekit
SDK Version
11.6.0
Framework Version
@sveltejs/kit 3.0.0
Link to Sentry event
No response
Reproduction Example/SDK Setup
Steps to Reproduce
+layout.server.tsload that doesn't readurl, so SvelteKit only reruns it when one of its own dependencies changes.wrapServerLoadWithSentry).Minimal check without an app, which is what we run in our tests:
Expected Result
The wrapper doesn't add a URL dependency to the load. Like 10.x, where
event.url.pathnamewas only read as a fallback span name when there's no route id.Actual Result
The layout load reruns on every navigation. The
url.pathattribute added in #24341 readsevent.url.pathnameoutsideuntrackinwrapLoadWithSentry(client and server) andwrapServerLoadWithSentry, so SvelteKit marks every wrapped load as depending on the pathname. With auto-instrumentation on, that's every load in the app, including root layouts that fetch session data.Additional Context
getRouteIdalready readsevent.route.idthroughevent.untrackfor exactly this reason. Reading the pathname the same way fixes it. We're carrying this as a patch on 11.6.0:Priority
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding
+1orme too, to help us triage it.