Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)

未关闭 适合新手
#11,358 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
frontend

调研方向

从 packages/solid-query/src/useMutation.ts 和 packages/solid-query/src/useBaseQuery.ts 开始,这里会在 observer 初始化期间读取 client() 和 options()。使用 Solid 2 和提供的组件场景进行复现,然后选择预期的未跟踪或延迟初始化方案。当挂载使用 useMutation 或 useQuery 的组件不再产生库的 STRICT_READ_UNTRACKED 诊断时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

With Solid 2 (solid-js@2.0.0-rc.4) and @tanstack/solid-query@6.0.0-rc.1, every component that calls useMutation (and useQuery) logs a reactivity diagnostic on mount:

[STRICT_READ_UNTRACKED] Reactive value read directly in <UnitCard> will not update.
Move it into a tracking scope (JSX, a memo, or an effect's compute function).
[STRICT_READ_UNTRACKED] repair guide: node_modules/solid-js/skills/reactivity-diagnostics/SKILL.md

Solid 2 ships these diagnostics in dev builds, and they are meant to be actionable: the console is expected to stay clean. Right now a single screen with a handful of mutations produces dozens of them, which drowns out the diagnostics that are about application code.

Cause

The hooks read memos directly in the component body, outside any tracking scope.

packages/solid-query/src/useMutation.ts:

const client = createMemo(() => resolveClient())

const observer = new MutationObserver(client(), options())   // ← read in component body

packages/solid-query/src/useBaseQuery.ts does the same when it creates its observer:

const initialOptions = defaultedOptions()

const [observer, setObserver] = createSignal(
  new Observer(client(), defaultedOptions()),               // ← read in component body
)

Both reads are intentional one-shot initialisations, so the value genuinely does not need to be tracked — which is exactly the case Solid's untrack exists for. Under Solid 1 this was silent; Solid 2 reports it.

Your minimal, reproducible example

Any component calling useMutation reproduces it. The official Solid 2 fullstack template does it out of the box:

https://github.com/solidjs/templates/tree/main/solid-v2/fullstack-tanstack

src/routes/users.$id.tsx calls useMutation; open the page with a dev build of solid-js@2 and the diagnostic appears on every mount.

Steps to reproduce
  1. Use solid-js@2.0.0-rc.4 with @tanstack/solid-query@6.0.0-rc.1.
  2. Render any component that calls useMutation (or useQuery).
  3. Watch the browser console on mount.
Expected behavior

No reactivity diagnostics from library code — the initial reads of client() / options() are untracked by design and should say so.

Suggested fix

Wrap the initialisation reads in untrack(...), or move observer creation into a createRenderEffect / memo. A related Solid-specific fix was already made in #10445 (useQueryClient running inside createMemo).

Platform
  • @tanstack/solid-query 6.0.0-rc.1 (latest rc on npm as of 2026-09-01)
  • solid-js 2.0.0-rc.4
  • Chromium 141, macOS
Note

Not filing a PR because I did not want to guess which of the two shapes (untrack vs. deferred observer creation) you prefer for v6 — happy to send one either way.

主要语言
TypeScript
星标
50.3k
派生
4.2k
平均合并
22 小时 33 分钟
30 天内合并 PR
214

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/query 的其他 Issue

查看 TanStack/query 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。