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

restoreQueries and persisterGc throw on malformed persisted entries

未关闭
#11,918 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@VGontier-cmd 已经在做这个了。

开始于 2026年10月6日。

  • #11919 来自 @VGontier-cmd —— 未关闭

评估

难度
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
  1. Open the reproduction; it runs automatically.
  2. Each case stores a broken entry followed by a valid query, then calls restoreQueries() or persisterGc().
  3. 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

环境准备

从这里开始

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

TanStack/query 的其他 Issue

查看 TanStack/query 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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