[vue-query] queryClient.fetchQuery passes getter options through without unwrapping
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- typescript
- 领域
- frontend, testing-qa
调研方向
从 @tanstack/vue-query QueryClient.fetchQuery 的实现及其对 cloneDeepUnref 的调用开始。查看 PR #11103 中链接的针对性回归测试,然后验证 getter 返回的选项对象在到达 query-core 之前会被求值并解包。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
QueryClient.fetchQuery in @tanstack/vue-query has an overload that accepts getter-function options, but the runtime implementation currently passes that top-level function through to query-core instead of evaluating it first.
The overload allows this shape:
queryClient.fetchQuery(() => ({
queryKey: ["foo", ref("bar")],
queryFn,
}))
But the implementation calls cloneDeepUnref(options) directly. cloneDeepUnref unwraps refs and nested query-key getters, but it does not call a top-level function value. As a result, query-core receives the function itself instead of the resolved FetchQueryOptions object.
Your minimal, reproducible example
Focused regression test in the linked PR: https://github.com/TanStack/query/pull/11103/files#diff-3d6cc18a7ff7e8e5afb08c0e3cba8d9f3e08fb9c6f6c59f1f5f58dc12f3f8b8e
Minimal code shape:
import { QueryClient } from "@tanstack/vue-query"
import { ref } from "vue"
const queryClient = new QueryClient()
const queryFn = () => Promise.resolve("mock")
queryClient.fetchQuery(() => ({
queryKey: ["foo", ref("bar")],
queryFn,
}))
Steps to reproduce
- Create a Vue Query
QueryClient. - Call
queryClient.fetchQuerywith a getter function returningFetchQueryOptions. - Observe that the getter is not evaluated before delegating to query-core.
A focused test shows the current behavior clearly:
queryClient.fetchQuery(() => ({
queryKey: queryKeyRef,
queryFn: fn,
}))
expect(QueryClientOrigin.prototype.fetchQuery).toHaveBeenCalledWith({
queryKey: queryKeyUnref,
queryFn: fn,
})
Currently the received argument is [Function anonymous].
Expected behavior
queryClient.fetchQuery(() => options) should evaluate the top-level getter, then deep-unref the returned options object before passing it to query-core.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: N/A
- Runtime: Node.js v24.13.0
- Adapter: vue-query
- Vue runtimes tested: Vue 2 / Vue 2.7 / Vue 3
Tanstack Query adapter
vue-query
TanStack Query version
v5.101.4 / current main branch at commit 86bb8a6fb
TypeScript version
TypeScript 5.9.3 in the local repo; package type tests also passed across the repo's configured TS 5.4 through TS 6.0 matrix.
Additional context
I could not find an existing open issue or PR for this with these searches:
vue queryClient fetchQuery getter options cloneDeepUnreffetchQuery getter function options vue-query
- 主要语言
- TypeScript
- 星标
- 50.6k
- 派生
- 4.2k
- 平均合并
- 9 小时 50 分钟
- 30 天内合并 PR
- 310
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/query 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
TanStack/query#12466 · 1 条评论 ·
维护者通常 1 天内回复
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)可能重新可做 @LeonxLJX 于 77 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
TanStack/query#11358 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
select that throws for placeholderData brings back the selection of data removed by resetQueries可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 3/5 1-2 天 新手友好度 56/100
维护者通常 1 天内回复
-
Render loop since v5.105.2 when placeholderData, or its select result, is not referentially stable未关闭
难度 4/5 3-5 天 新手友好度 54/100
维护者通常 1 天内回复
-
useQueries: stable combine returns a stale result when a query updates before setQueries runs可能已有人在做 @sakaintp 于 1 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 62/100
TanStack/query#12626 · 2 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复