feat(svelte-query): propagate errors to the nearest svelte:boundary when throwOnError is set - #11319
Draft
sukvvon wants to merge 1 commit into
Draft
feat(svelte-query): propagate errors to the nearest svelte:boundary when throwOnError is set#11319sukvvon wants to merge 1 commit into
sukvvon wants to merge 1 commit into
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 07eca19
☁️ Nx Cloud last updated this comment at |
Contributor
🚀 Changeset Version Preview1 package(s) bumped directly, 3 bumped as dependents. 🟨 Minor bumps
|
Contributor
size-limit report 📦
|
…hen throwOnError is set
sukvvon
force-pushed
the
feat/svelte-query-throwonerror-render-throw
branch
from
August 28, 2026 06:58
a6d9b58 to
07eca19
Compare
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.
🎯 Changes
createQuery/createInfiniteQuerynever threw errors from the render path whenthrowOnErrorwas set — thethrowOnErroroption was accepted (typed) but had no runtime effect for these hooks. This contradicts the documented behavior (docs/framework/svelte/quick-start.md): "SetthrowOnErroroption totrueto make sure errors are thrown to the<svelte:boundary>component."Added a dedicated
$effectincreateBaseQuery.svelte.ts(shared by bothcreateQueryandcreateInfiniteQuery) that throws whenshouldThrowErrorreturns true. The throw must happen from inside a Svelte reaction — verified experimentally that throwing from thesubscribecallback (which runs throughnotifyManager's batching, outside any active Svelte reaction) never reaches<svelte:boundary>and instead becomes an unhandled error.The reaction reads
observer.getCurrentResult()(untracked) rather than thequeryresult object returned to consumers, gated behind a separateresultVersioncounter. Readingquery.isError/query.isFetchingdirectly would mark them tracked on thetrackResultproxy the first time an error occurs, permanently wideningnotifyOnChangePropsfor every consumer of that query from then on — verified with a regression test that reproduces the pollution (1 vs 4 re-runs) before/after this change.This still notifies reliably because
queryObserver.tsforce-adds'error'to the notified props wheneveroptions.throwOnErroris set, regardless of what any consumer has read. This is a load-bearing dependency on that query-core internal — flagging it here for visibility.createQueries.svelte.tsis out of scope for this PR — same defect, separate change.Also out of scope: the
QueryErrorResetBoundary/errorResetBoundaryreset machinery react-query has (retryOnMountsuppression while unreset). Svelte 5's<svelte:boundary>gives areset()callback to thefailedsnippet directly, a different primitive — mapping React's reset model onto it is a separate design decision.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact