Skip to content

fix(svelte-query): state_unsafe_mutation error with useIs... #9493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: svelte-5-adapter
Choose a base branch
from

Conversation

hmnd
Copy link

@hmnd hmnd commented Jul 24, 2025

Fixes the bug reported by @frederikhors here.

I thoroughly dug into this issue until I found calls to Observer and MutataionOBserver were wrapped in a $derived(...) in order to make them reactive to the passed in client. This was resulting in unsafe mutation errors, and there was already an $effect.pre(...) used for updating options when they changed, so aside from the client reactivity, the $derived wasn't necessary.

To support reactivity for queryClient, the observer is now a $state and is reassigned whenever the client changes.

The useIsFetching and useIsMutating tests were previously passing because they used a QueryClient local to the component, rather than one from context. I've updated the tests to use a provider instead, in order to properly repro this issue.

…afe_mutation

fixes useIsFetching and useIsMutating in svelte 5 adapter
@hmnd hmnd force-pushed the fix/svelte-query-isfetching branch from dd04604 to e22d61e Compare July 24, 2025 22:46
@lachlancollins lachlancollins self-requested a review July 25, 2025 02:40
Copy link

nx-cloud bot commented Jul 25, 2025

View your CI Pipeline Execution ↗ for commit 4f57fd5

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

☁️ Nx Cloud last updated this comment at 2025-07-25 02:42:44 UTC

Copy link

pkg-pr-new bot commented Jul 25, 2025

More templates

@tanstack/angular-query-devtools-experimental

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

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 4f57fd5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant