Mutation status incorrect after navigation in SvelteKit
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- frontend
Direzione di ricerca
Inizia con il CodeSandbox collegato o il repository di riproduzione e con l’handler onSuccess della mutation signIn. Riproduci la navigazione verso /auth e ritorno, confrontando lo stato della mutation con gli strumenti per sviluppatori di TanStack Query, soprattutto quando viene eseguito invalidateQueries({ queryKey: ['customer'] }). È completato quando lo stato è success dopo il ritorno a / senza rimuovere l’invalidazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Hi!
After navigating to another page in a SvelteKit app, an ongoing mutation's status remains pending instead of success
Your minimal, reproducible example
https://codesandbox.io/p/github/EugeneDraitsev/svelte-tanstack-query-mutation-status-issue/master
Steps to reproduce
You can check codesandbox link or check my repo: https://github.com/EugeneDraitsev/svelte-tanstack-query-mutation-status-issue
I have pretty simple mutation:
export const signIn = createMutation(
{
mutationFn: async () => {
// wait for 1 second
await new Promise((resolve) => setTimeout(resolve, 1000));
},
onSuccess: async () => {
await goto('/auth');
await queryClient.invalidateQueries({ queryKey: ['customer'] });
},
},
queryClient,
);
When a user clicks the Sign In button, I simulate a login and redirect the user to the /auth route. However, when I navigate back from the /auth page to /, I see that $signIn.status is pending instead of success. I also can see the correct success status in the TanStack Query devtools.
If I comment out await queryClient.invalidateQueries({ queryKey: ['customer'] }); in the onSuccess function, everything works fine. However, I still consider this behavior as a bug.
Expected behavior
My mutation has success status
How often does this bug happen?
None
Screenshots or Videos
https://github.com/user-attachments/assets/7e56dedc-c841-4552-97a3-a3f177702d86
Platform
- OS: Windows 11 24H2
- Browser: Chrome
- Version: 134.0.6998.35 (Official Build) (64-bit)
Tanstack Query adapter
None
TanStack Query version
^5.67.2
TypeScript version
^5.0.0
Additional context
No response
- Lingua principale
- TypeScript
- Stelle
- 50.3k
- Fork
- 4.2k
- Merge medio
- 22h 33m
- PR unite (30g)
- 214
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/query
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Tutte le issue di TanStack/query
Issue simili
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Crush Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
ElementsProject/cln-application#167 · 1 commento · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Quantco/pnpm-licenses#17 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100