Repository navigation
fix(sveltekit): Read load event pathname untracked - #25235
Conversation
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>
|
bugbot run |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
bugbot 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>
|
bugbot run |
There was a problem hiding this comment.
✅ 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.
size-limit report 📦
|
| [SENTRY_ORIGIN]: 'auto.function.sveltekit', | ||
| [SENTRY_SEGMENT_NAME_SOURCE]: routeId ? 'route' : 'url', | ||
| [URL_PATH]: event.url.pathname, | ||
| [URL_PATH]: pathname, |
There was a problem hiding this comment.
We should make sure that dataCollection.urlQueryParams is respected here as well.
There was a problem hiding this comment.
This should be fine as the path never contains query strings
JPeer264
left a comment
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
super-l: Wouldn't this be the same?
| const routeOrPathname = routeId ? routeId : pathname; | |
| const routeOrPathname = routeId || pathname; |
The
url.pathattribute added in #24341 made the load wrappers readevent.url.pathnameoutsideuntrack. 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 waygetRouteIdalready readsroute.id. On SvelteKit 2 versions that don't haveuntrackyet, it calls the nativeURL.prototypegetter instead. SvelteKit's tracking getter is an own property onevent.url, so the native getter skips it.Fixes #25231