Skip to content

test(query-persist-client-core/createPersister): add tests for removing entries that fail to deserialize#10881

Merged
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-persister-deserialize-failure
Jun 4, 2026
Merged

test(query-persist-client-core/createPersister): add tests for removing entries that fail to deserialize#10881
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-persister-deserialize-failure

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 4, 2026

🎯 Changes

Adds unit tests for persisterGc, restoreQueries, and removeQueries covering the case where a stored entry cannot be deserialized: the corrupted entry is removed from storage and iteration continues.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 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

  • Tests
    • Added test coverage for data validation and cleanup scenarios.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe4e2ccb-10a8-4c01-816a-b7387bc7940a

📥 Commits

Reviewing files that changed from the base of the PR and between 79e639e and 02e3af3.

📒 Files selected for processing (1)
  • packages/query-persist-client-core/src/__tests__/createPersister.test.ts

📝 Walkthrough

Walkthrough

This PR adds three Vitest test cases to createPersister.test.ts ensuring persisterGc, restoreQueries, and removeQueries properly clean up invalid (non-JSON) persisted data from storage without errors or unintended side effects.

Changes

Invalid persisted data cleanup coverage

Layer / File(s) Summary
Invalid persisted data cleanup across persister methods
packages/query-persist-client-core/src/__tests__/createPersister.test.ts
Tests for persisterGc, restoreQueries, and removeQueries each seed storage with non-deserializable content, invoke the corresponding method, and assert the invalid entry is removed from storage.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • TanStack/query#10876: Both PRs add Vitest coverage for invalid persisted cache entries being removed during restore/invalidation flows in query-persist-client-core.

Poem

🐰 Invalid data? Fear not, dear friend!
Our tests now catch the corrupted end—
JSON that breaks, we clean with care,
Three methods verified everywhere! 🧹

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: adding tests for removing entries that fail to deserialize in the createPersister module.
Description check ✅ Passed The pull request description follows the required template with all sections completed, including Changes, Checklist with both items checked, and Release Impact properly marked as dev-only.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/query-persist-client-core-persister-deserialize-failure

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Jun 4, 2026

View your CI Pipeline Execution ↗ for commit 02e3af3

Command Status Duration Result
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 5s View ↗
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 3m 35s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-04 05:49:34 UTC

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 4, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10881

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10881

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@10881

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10881

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10881

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10881

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10881

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10881

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10881

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10881

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10881

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10881

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10881

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10881

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10881

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10881

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10881

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10881

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10881

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10881

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10881

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10881

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10881

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10881

commit: 02e3af3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

size-limit report 📦

Path Size
react full 12.11 KB (0%)
react minimal 9.08 KB (0%)

@sukvvon sukvvon merged commit 0a0e2d9 into main Jun 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-persist-client-core-persister-deserialize-failure branch June 4, 2026 05:52
@sukvvon sukvvon self-assigned this Jun 4, 2026
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.

1 participant