Skip to content

SvelteKit: load wrappers read event.url.pathname tracked, so every instrumented load reruns on navigation #25231

Description

@ndri

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

  1. Add a +layout.server.ts load that doesn't read url, so SvelteKit only reruns it when one of its own dependencies changes.
  2. Enable load auto-instrumentation (or wrap the load with wrapServerLoadWithSentry).
  3. 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.

Activity

  1. linear-code commented on Oct 9, 2026

    @linear-code
  2. self-assigned this
    on Oct 9, 2026
  3. chargome commented on Oct 9, 2026

    @chargome
    Member

    @ndri thanks for the report, we'll check it out!

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions