{{ message }}
Repository navigation
Conversation
For queries without cached data, queryFn executes synchronously inside the subscription effect (onSubscribe -> shouldFetchOnMount -> fetch). Any reactive state read by queryFn before its first await was therefore recorded as a dependency of that effect: writes to the state tore the observer down (cancelling the in-flight fetch) and re-subscribed, starting a new fetch from a still-dataless query — indefinitely. Keep the observer read tracked so changing options still re-subscribes, but run the subscription itself inside untrack().
Contributor
4 of 5 tasks
This branch has not been deployed
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.

Fixes #11541
🎯 Changes
For queries without cached data,
queryFnexecutes synchronously inside the subscription$effect(onSubscribe→shouldFetchOnMount→fetch). Any reactive state read byqueryFnbefore its firstawaitwas therefore recorded as a dependency of that effect. Writes to that state tore the observer down (cancelling the in-flight fetch) and re-subscribed — and since the query stays dataless, every re-subscription starts a new fetch: an unbounded teardown/refetch loop. See #11541 for the full mechanism and the exact set of conditions that sustain it.The fix keeps the
observerread tracked, but runs the subscription itself insideuntrack():Note: the naive
untrack(() => observer.subscribe(...))is not enough — it also untracks theobserverread, so changing queries would no longer re-subscribe. The existing test “should track queries added to an initially empty array” catches that case, which is why the observer read stays outside theuntrack().Applied to both
createBaseQuery.svelte.ts(also coverscreateInfiniteQuery) andcreateQueries.svelte.ts.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests