restoreQueries and persisterGc throw on malformed persisted entries
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- backend
调研方向
Start by locating experimental_createQueryPersister and the implementations of restoreQueries() and persisterGc(); compare how they handle invalid JSON with parsed values such as null or {}. Run the reproduction linked in the issue and relevant persister tests. Done means malformed entries are removed without throwing, remaining valid queries are processed, and valid query data of null still restores correctly.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When using experimental_createQueryPersister, restoreQueries() throws if a stored entry contains "null", "{}" or '{"state":null}'. The entry stays in storage and the next valid query is not restored.
persisterGc() also throws on these entries.
With invalid JSON like "not-json{", the entry is removed and processing continues. I would expect the same behavior for these values.
Your minimal, reproducible example
https://stackblitz.com/edit/bqs8bszm?file=index.js
Steps to reproduce
- Open the reproduction; it runs automatically.
- Each case stores a broken entry followed by a valid query, then calls restoreQueries() or persisterGc().
- The invalid JSON cases pass, but "null", "{}" and '{"state":null}' cause a TypeError. For restoreQueries(), the next valid query is not restored.
Expected behavior
The malformed entry should be removed without throwing, and processing should continue with the remaining entries.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: macOS 27.0
- Browser: Chromium 154.0.8037.98 (verified with Playwright)
Tanstack Query adapter
vanilla
TanStack Query version
5.104.1 for both @tanstack/query-core and @tanstack/query-persist-client-core
TypeScript version
No response
Additional context
The valid query in the reproduction has null as its data. This is intentional: null query data should still be restored correctly.
- 主要语言
- TypeScript
- 星标
- 50.4k
- 派生
- 4.2k
- 平均合并
- 7 小时 29 分钟
- 30 天内合并 PR
- 393
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/query 的其他 Issue
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
TanStack/query#11358 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
solid-query: switching the queryClient accessor strands the new client's cache (subscription stays on the old observer)可能已有人在做 @MaNaN1803 于 75 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
TanStack/query#11106 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
setQueryData: NoInfer loses discriminated-union members when spreading a narrowed updater value可能已有人在做 @iosayin 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
setQueryData updater loses discriminated-union fields when spreading inferred NoInfer data可能已有人在做 @boriskozak 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 68/100
TanStack/query#11794 · 1 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
triage
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
agent-ready area: config area: skills type: chore upstream: brain-kit
难度 1/5 1 小时以内 新手友好度 95/100
-
enhancement priority:low ready-for-dev
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
bug escritorio mapa
难度 2/5 1-3 小时 新手友好度 72/100
marcosferr/reporte-ciudadano#4 · 1 条评论 ·
-
area: material/sort gemini-triaged needs triage
难度 2/5 1-3 小时 新手友好度 70/100
angular/components#33933 ·
维护者通常 1 天内回复