Skip to content

test(query-persist-client-core/createPersister): add test for 'persisterGc' keeping valid entries#10882

Merged
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-persister-gc-keep-valid
Jun 4, 2026
Merged

test(query-persist-client-core/createPersister): add test for 'persisterGc' keeping valid entries#10882
sukvvon merged 1 commit into
mainfrom
test/query-persist-client-core-persister-gc-keep-valid

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Jun 4, 2026

🎯 Changes

Adds a unit test for persisterGc covering the case where a stored entry is neither expired nor busted: the entry is kept in storage instead of being removed.

The existing tests only cover the removal path, so this fills in the complementary "keep valid entry" branch.

✅ 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 garbage collection behavior to verify storage entries persist when neither expired nor invalidated.

@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: da474393-e331-424b-85d4-68e8df7e6815

📥 Commits

Reviewing files that changed from the base of the PR and between 0a0e2d9 and 8630efb.

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

📝 Walkthrough

Walkthrough

This PR adds a test case to verify that the garbage collection function (persisterGc()) preserves cache entries that remain valid—neither expired by maxAge nor invalidated by buster logic. The test persists a query and confirms the storage entry count remains unchanged after garbage collection.

Changes

Cache GC preservation coverage

Layer / File(s) Summary
GC preservation test for non-expired, non-busted entries
packages/query-persist-client-core/src/__tests__/createPersister.test.ts
New persisterGc test case verifies that storage entries are retained when neither expired nor busted, by asserting storage entry count remains 1 after running garbage collection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/query#10881: Both PRs test persisterGc behavior—this one verifies preservation of non-expired/non-busted entries, while #10881 tests removal of non-deserializable/corrupted entries.
  • TanStack/query#10876: Related test coverage exercising the same cache expiration and buster invalidation logic, though from a different code path.

Poem

🐰 A test hops in to check the cache,
"Keep entries safe!" it says with grace—
No expiration, no bust in sight,
GC preserves them, all seems right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a test case for 'persisterGc' that verifies valid entries are kept, which aligns with the changeset details.
Description check ✅ Passed The description covers the main changes, rationale, and all required checklist items with appropriate selections; the PR is marked as dev-only which correctly reflects that only test code was modified.
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-gc-keep-valid

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 8630efb

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

☁️ Nx Cloud last updated this comment at 2026-06-04 06:02:35 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@10882

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

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

@tanstack/preact-query

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

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

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

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 8630efb

@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 self-assigned this Jun 4, 2026
@sukvvon sukvvon merged commit c4b39ff into main Jun 4, 2026
9 checks passed
@sukvvon sukvvon deleted the test/query-persist-client-core-persister-gc-keep-valid branch June 4, 2026 06:06
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