Mutation status incorrect after navigation in SvelteKit
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 50/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
リンクされた CodeSandbox または再現用リポジトリと、signIn mutation の onSuccess ハンドラーから始めます。TanStack Query devtools で mutation のステータスを比較しながら、/auth への遷移とそこからの復帰を再現します。特に invalidateQueries({ queryKey: ['customer'] }) が実行される場合を確認します。/ に戻った後も invalidation を削除せずにステータスが success になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 50.3k
- フォーク
- 4.2k
- 平均マージ
- 22時間 33分
- マージ済み PR(30日)
- 214
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/query のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 40/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
似ている issue
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
Crush オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
ElementsProject/cln-application#167 · コメント 1 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Quantco/pnpm-licenses#17 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100