Skip to content

fix(sveltekit): Read load event pathname untracked - #25235

Merged
chargome merged 3 commits into
developfrom
sveltekit-load-pathname
Oct 12, 2026
Merged

chargome merged 3 commits into
developfrom
sveltekit-load-pathname

Conversation

@chargome

@chargome chargome commented Oct 9, 2026

Copy link
Copy Markdown
Member

The url.path attribute added in #24341 made the load wrappers read event.url.pathname outside untrack. SvelteKit took that as the load depending on the URL, so every wrapped load reran on each navigation. With auto-instrumentation on, that's every load in the app.

The pathname is now read through event.untrack, the same way getRouteId already reads route.id. On SvelteKit 2 versions that don't have untrack yet, it calls the native URL.prototype getter instead. SvelteKit's tracking getter is an own property on event.url, so the native getter skips it.

Fixes #25231

The load wrappers read event.url.pathname for the url.path attribute
outside of untrack, so SvelteKit marked every wrapped load as depending
on the URL and reran it on each navigation. Read the pathname through
untrack, or the native URL getter when untrack is unavailable.

Fixes #25231
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chargome chargome self-assigned this Oct 9, 2026
@chargome

chargome commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

bugbot run

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

Stale Bugbot comment from a previous run.

Comment thread packages/sveltekit/test/client/load.test.ts Outdated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chargome

chargome commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

bugbot run

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

Stale Bugbot comment from a previous run.

…ation

Covers #25231 in a real app: a wrapped layout server load that doesn't
read url must not rerun when navigating between its child pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chargome

Copy link
Copy Markdown
Member Author

bugbot run

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d66cf2b. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 29.82 kB - -
@sentry/browser - with treeshaking flags 27.95 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.86 kB - -
@sentry/browser (incl. Tracing) 51.88 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 51.9 kB - -
@sentry/browser (incl. Tracing, Profiling) 54.83 kB - -
@sentry/browser (incl. Tracing, Replay) 91.65 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.5 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 96.37 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 109.33 kB - -
@sentry/browser (incl. Feedback) 47.34 kB - -
@sentry/browser (incl. sendFeedback) 34.87 kB - -
@sentry/browser (incl. FeedbackAsync) 39.98 kB - -
@sentry/browser (incl. Metrics) 30.84 kB - -
@sentry/browser (incl. Logs) 31.13 kB - -
@sentry/browser (incl. Metrics & Logs) 31.77 kB - -
@sentry/react 31.65 kB - -
@sentry/react (incl. Tracing) 54.21 kB - -
@sentry/vue 37.89 kB - -
@sentry/vue (incl. Tracing) 54.81 kB - -
@sentry/svelte 29.84 kB - -
@sentry/remix (Remix 3 client bundle) 56.91 kB - -
CDN Bundle 31.55 kB - -
CDN Bundle (incl. Tracing) 52.41 kB - -
CDN Bundle (incl. Logs, Metrics) 33.75 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.34 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.67 kB - -
CDN Bundle (incl. Tracing, Replay) 90.06 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.18 kB - -
CDN Bundle - uncompressed 92.91 kB - -
CDN Bundle (incl. Tracing) - uncompressed 155.53 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.45 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.48 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.48 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.7 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 281.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.33 kB - -
@sentry/nextjs (client) 56.62 kB - -
@sentry/sveltekit (client) 52.27 kB - -
@sentry/core/server 40.88 kB - -
@sentry/core/browser 13.74 kB - -
@sentry/node 151.72 kB +0.01% +4 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.77 kB - -
@sentry/node - without tracing 94.29 kB +0.02% +12 B 🔺
@sentry/node - without channel injection 129.9 kB +0.01% +8 B 🔺
@sentry/aws-serverless 102.44 kB +0.01% +2 B 🔺
@sentry/cloudflare (withSentry) - minified 210.2 kB - -
@sentry/cloudflare (withSentry) 521.15 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 227.88 kB - -

View base workflow run

@chargome
chargome marked this pull request as ready for review October 12, 2026 09:34
@chargome
chargome requested a review from a team as a code owner October 12, 2026 09:34
@chargome
chargome requested review from Lms24, nicohrubec and s1gr1d and removed request for a team October 12, 2026 09:34
[SENTRY_ORIGIN]: 'auto.function.sveltekit',
[SENTRY_SEGMENT_NAME_SOURCE]: routeId ? 'route' : 'url',
[URL_PATH]: event.url.pathname,
[URL_PATH]: pathname,

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.

We should make sure that dataCollection.urlQueryParams is respected here as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This should be fine as the path never contains query strings

@chargome
chargome requested a review from s1gr1d October 12, 2026 11:37
@chargome
chargome merged commit 938c7ea into develop Oct 12, 2026
359 checks passed
@chargome
chargome deleted the sveltekit-load-pathname branch October 12, 2026 12:55

@JPeer264 JPeer264 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'm too late, anyways. here a review:

const routeId = getRouteId(event) ?? undefined;
const routeOrPathname = routeId ? routeId : event.url.pathname;
const pathname = getPathname(event);
const routeOrPathname = routeId ? routeId : pathname;

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.

super-l: Wouldn't this be the same?

Suggested change
const routeOrPathname = routeId ? routeId : pathname;
const routeOrPathname = routeId || pathname;

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.

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

3 participants