FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(svelte-query): propagate errors to the nearest svelte:boundary when throwOnError is set by sukvvon · Pull Request #11319 · TanStack/query · GitHub

/ query Public

feat(svelte-query): propagate errors to the nearest svelte:boundary when throwOnError is set - #11319

Draft
sukvvon wants to merge 1 commit into
mainfrom
feat/svelte-query-throwonerror-render-throw
Draft

feat(svelte-query): propagate errors to the nearest svelte:boundary when throwOnError is set#11319
sukvvon wants to merge 1 commit into
mainfrom
feat/svelte-query-throwonerror-render-throw

Conversation

sukvvon commented Aug 28, 2026
edited
Loading

Copy link
Copy Markdown
Member

🎯 Changes

createQuery/createInfiniteQuery never threw errors from the render path when throwOnError was set — the throwOnError option was accepted (typed) but had no runtime effect for these hooks. This contradicts the documented behavior (docs/framework/svelte/quick-start.md): "Set throwOnError option to true to make sure errors are thrown to the <svelte:boundary> component."

Added a dedicated $effect in createBaseQuery.svelte.ts (shared by both createQuery and createInfiniteQuery) that throws when shouldThrowError returns true. The throw must happen from inside a Svelte reaction — verified experimentally that throwing from the subscribe callback (which runs through notifyManager'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 the query result object returned to consumers, gated behind a separate resultVersion counter. Reading query.isError/query.isFetching directly would mark them tracked on the trackResult proxy the first time an error occurs, permanently widening notifyOnChangeProps for 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.ts force-adds 'error' to the notified props whenever options.throwOnError is 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.ts is out of scope for this PR — same defect, separate change.

Also out of scope: the QueryErrorResetBoundary/errorResetBoundary reset machinery react-query has (retryOnMount suppression while unreset). Svelte 5's <svelte:boundary> gives a reset() callback to the failed snippet directly, a different primitive — mapping React's reset model onto it is a separate design decision.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nx-cloud Bot commented Aug 28, 2026
edited
Loading

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 07eca19

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 3m 45s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-28 07:03:38 UTC

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 3 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/svelte-query 6.1.48 → 6.2.0 Changeset
@tanstack/svelte-query-devtools 6.1.48 → 6.2.0 Dependent
@tanstack/svelte-query-persist-client 6.1.48 → 6.2.0 Dependent
@tanstack/vue-query-devtools 6.1.48 → 6.2.0 Dependent

pkg-pr-new Bot commented Aug 28, 2026
edited
Loading

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11319

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11319

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11319

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11319

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11319

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11319

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11319

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11319

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11319

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11319

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11319

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11319

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11319

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11319

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11319

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11319

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11319

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11319

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11319

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11319

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11319

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11319

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11319

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11319

commit: 07eca19

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.89 KB (0%)
react minimal 8.85 KB (0%)

sukvvon self-assigned this Aug 28, 2026
sukvvon force-pushed the feat/svelte-query-throwonerror-render-throw branch from a6d9b58 to 07eca19 Compare August 28, 2026 06:58
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL