Skip to content

fix(db): release synced keys after delete - #1787

Open
IdoZ14 wants to merge 2 commits into
TanStack:mainfrom
IdoZ14:idoz/fix-synced-keys-retention
Open

fix(db): release synced keys after delete#1787
IdoZ14 wants to merge 2 commits into
TanStack:mainfrom
IdoZ14:idoz/fix-synced-keys-retention

Conversation

@IdoZ14

@IdoZ14 IdoZ14 commented Aug 31, 2026

Copy link
Copy Markdown

🎯 Changes

  • Remove deleted row keys from CollectionStateManager.syncedKeys during synced deletes.
  • Add a focused two-key regression test that verifies only the deleted key is removed.
  • Add an @tanstack/db patch changeset.

The regression test inserts two rows and deletes one. Before this fix, the deleted row’s key remains in syncedKeys; after the fix, only the surviving row’s key remains.

Closes #1786

Testing

  • pnpm build — passed
  • pnpm test — passed across all 28 workspace packages
  • @tanstack/db — 3,324 tests passed, 6 skipped; no type errors
  • Focused regression test — confirmed failing without the fix and passing with it
  • ESLint on the changed TypeScript files — no errors

✅ Checklist

  • I have tested this code locally with pnpm test.

🚀 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

    • Deleted rows are now correctly removed from sync tracking, preventing stale deleted keys from being retained.
  • Tests

    • Added coverage verifying that sync tracking includes inserted rows and removes them after deletion.
  • Release

    • Prepared a patch release for the database package.

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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 Plus

Run ID: c7893c34-2807-44cc-9493-019e1980f5aa

📥 Commits

Reviewing files that changed from the base of the PR and between bda2303 and fd4be96.

📒 Files selected for processing (3)
  • .changeset/release-deleted-sync-keys.md
  • packages/db/src/collection/state.ts
  • packages/db/tests/collection.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The synced delete path now removes deleted keys from syncedKeys. A collection regression test verifies the set contents after deletion. A patch changeset records the release for @tanstack/db.

Changes

Synced key deletion

Layer / File(s) Summary
Delete tracking and regression coverage
packages/db/src/collection/state.ts, packages/db/tests/collection.test.ts, .changeset/release-deleted-sync-keys.md
The delete branch removes the key from syncedKeys. The test verifies that deleting key 1 changes the set from {1, 2} to {2}. The changeset declares a patch release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to fd4be

The fix removes deleted row keys from synchronized state while preserving surviving keys, with focused regression coverage and passing checks. No actionable merge-blocking risk remains.

Suggested reviewers: kyleamathews, samwillis, kevin-dp

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: removing synced keys after deletion.
Description check ✅ Passed The description explains the change, motivation, regression test, validation results, checklist completion, and patch changeset.
Linked Issues check ✅ Passed The implementation and regression test satisfy issue #1786 by removing deleted keys from syncedKeys and verifying that only surviving keys remain.
Out of Scope Changes check ✅ Passed The changeset, implementation fix, and focused regression test are directly related to issue #1786. No unrelated code changes are identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@IdoZ14
IdoZ14 marked this pull request as ready for review August 31, 2026 12:45
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.

Synced deletes retain keys indefinitely in CollectionStateManager.syncedKeys

1 participant