Mutation status incorrect after navigation in SvelteKit
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 50/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
从链接的 CodeSandbox 或复现仓库以及 signIn mutation 的 onSuccess 处理程序开始。在使用 TanStack Query devtools 对比 mutation 状态的同时,复现导航到 /auth 再返回的过程,尤其要关注 invalidateQueries({ queryKey: ['customer'] }) 运行时的情况。完成的标准是:返回 / 后状态为 success,同时不移除 invalidation。
由索引模型根据 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 分钟
- 30 天内合并 PR
- 214
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 ·
-
难度 1/5 1 小时以内 新手友好度 90/100
ElementsProject/cln-application#167 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Quantco/pnpm-licenses#17 ·
-
难度 2/5 1-3 小时 新手友好度 75/100