Skip to content

fix(query-persist-client-core): handle nullish persisted query state - #11919

Open
VGontier-cmd wants to merge 1 commit into
TanStack:mainfrom
VGontier-cmd:fix/persister-malformed-entries
Open

VGontier-cmd wants to merge 1 commit into
TanStack:mainfrom
VGontier-cmd:fix/persister-malformed-entries

Conversation

@VGontier-cmd

@VGontier-cmd VGontier-cmd commented Oct 6, 2026 •

Copy link
Copy Markdown

🎯 Changes

Fixes #11918.

Treat null persisted values and missing/null state as entries without dataUpdatedAt, so restoreQueries() and persisterGc() remove them and continue instead of throwing.

The internal expiry check accepts this input shape; public types are unchanged. Tests cover removing the malformed entry, processing subsequent entries, preserving valid null query data, and the existing retrieveQuery() behavior.

Verified locally:

  • The six new restoration/GC cases fail before the fix and pass after it.
  • pnpm nx run @tanstack/query-persist-client-core:test:lib — 65 tests passed.
  • pnpm run build:all — 25 packages built.
  • pnpm run test:pr — all 128 tasks passed.
  • The original reproduction passes all eight cases against the local build.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Malformed or incomplete persisted query entries are now removed during retrieval, cleanup, and restoration without interrupting processing of other entries.

@changeset-bot

changeset-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c33c2a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@tanstack/query-persist-client-core Patch
@tanstack/preact-query-persist-client Patch
@tanstack/preact-query Patch
@tanstack/query-async-storage-persister Patch
@tanstack/query-sync-storage-persister Patch
@tanstack/react-query-persist-client Patch
@tanstack/react-query Patch
@tanstack/solid-query-persist-client Patch
@tanstack/svelte-query-persist-client Patch
@tanstack/angular-query-experimental Patch
@tanstack/eslint-plugin-query Patch
@tanstack/preact-query-devtools Patch
@tanstack/query-broadcast-client-experimental Patch
@tanstack/query-core Patch
@tanstack/query-devtools Patch
@tanstack/react-query-devtools Patch
@tanstack/react-query-next-experimental Patch
@tanstack/solid-query-devtools Patch
@tanstack/solid-query Patch
@tanstack/vue-query Patch
@tanstack/svelte-query-devtools Patch
@tanstack/svelte-query Patch
@tanstack/vue-query-devtools Patch
@tanstack/lit-query Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/query/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09f6c8ee-54db-42f2-b16a-8e8d3a2c77ca
📥 Commits

Reviewing files that changed from the base of the PR and between d169ee8 and c33c2a3.

📒 Files selected for processing (3)
  • .changeset/proud-donuts-shave.md
  • packages/query-persist-client-core/src/__tests__/createPersister.test.ts
  • packages/query-persist-client-core/src/createPersister.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The persister now identifies entries with missing or null state as expired or busted. Tests cover their removal during retrieval, garbage collection, and restoration, including restoration of a subsequent valid query.

Changes

Malformed persisted entry handling

Layer / File(s) Summary
Check and remove malformed entries
packages/query-persist-client-core/src/createPersister.ts, packages/query-persist-client-core/src/__tests__/createPersister.test.ts, .changeset/proud-donuts-shave.md
isExpiredOrBusted accepts nullable or incomplete persisted entries. Tests cover removal during retrieval, garbage collection, and restoration, while confirming that valid query data is restored. A patch changeset records the change.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: sukvvon

Merge Risk: ⚪ Minimal · up to c33c2

No actionable issue introduced by this change remains; it is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix: handling nullish persisted query state in query-persist-client-core.
Description check ✅ Passed The description explains the change and motivation, includes the required checklist and release-impact sections, and reports testing and changeset status.
Linked Issues check ✅ Passed Issue #11918 requires malformed persisted entries to be removed without throwing, with processing continuing and valid queries with null data preserved. isExpiredOrBusted now treats nullish entries …
Out of Scope Changes check ✅ Passed The source change, regression tests, and changeset all support the malformed-entry handling required by issue #11918. The reviewed diff shows no unrelated changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@VGontier-cmd
VGontier-cmd marked this pull request as ready for review October 6, 2026 08:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

restoreQueries and persisterGc throw on malformed persisted entries

1 participant