Repository navigation
fix(sveltekit): Read navigation untracked in the Kit 3 fetch wrapper - #26136
Merged
Merged
Conversation
The SvelteKit 3 fetch wrapper read `navigating` from `$app/state` tracked. A `$effect` that calls fetch synchronously then picked up `navigating` as a dependency and re-ran (re-sending its requests) on every navigation. Read it with `untrack` instead. Fixes #26129 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
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 fd1e36e. Configure here.
Contributor
size-limit report 📦Compared: 3b9c070 (PR test merge using develop at c054e7a) Against: c054e7a (develop) · base run #65086 ✅ Baseline matches: this diff contains only this PR's changes.
|
chargome
marked this pull request as ready for review
November 5, 2026 14:00
chargome
requested review from
Lms24,
andreiborza,
isaacs,
logaretm,
nicohrubec and
s1gr1d
and removed request for
a team,
isaacs,
logaretm and
s1gr1d
November 5, 2026 14:00
Lms24
approved these changes
Nov 5, 2026
| */ | ||
| export function getCurrentNavigation(): Navigation | null { | ||
| return _snapshot(); | ||
| return untrack(_snapshot); |
Member
There was a problem hiding this comment.
Just to double-check: This file is only pulled in on Svelte 5, correct? Just to make sure we don't break someone on Svelte 4 where I think this function wasn't available.
Member
Author
There was a problem hiding this comment.
Yes, just used on svelte5BrowserTracing.ts
43081j
pushed a commit
to 43081j/sentry-javascript
that referenced
this pull request
Nov 9, 2026
…etsentry#26136) **Why:** On SvelteKit 3 the fetch wrapper reads `navigating` from `$app/state` before every request. When a `$effect` calls `fetch` synchronously, that read made `navigating` a dependency of the effect, so it re-ran (and re-sent its requests) on every navigation. The read now goes through `untrack`. `svelte` is marked external in rollup so the import resolves to the app's Svelte 5, and a small build-time `.d.ts` declares `untrack` because the package is type-checked against Svelte 4. **How to review:** The fix is one line in `navigationState.svelte.ts`. The new e2e test in `sveltekit-3` fails without it (4 requests instead of 1). Closes getsentry#26129 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
51 tasks done
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: On SvelteKit 3 the fetch wrapper reads
navigatingfrom$app/statebefore every request. When a$effectcallsfetchsynchronously, that read madenavigatinga dependency of the effect, so it re-ran (and re-sent its requests) on every navigation. The read now goes throughuntrack.svelteis marked external in rollup so the import resolves to the app's Svelte 5, and a small build-time.d.tsdeclaresuntrackbecause the package is type-checked against Svelte 4.How to review: The fix is one line in
navigationState.svelte.ts. The new e2e test insveltekit-3fails without it (4 requests instead of 1).Closes #26129