-
Notifications
You must be signed in to change notification settings - Fork 124
Fixed query collection bug where optimistic state leaked into syncedData when using writeInsert inside onInsert handlers #879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed query collection bug where optimistic state leaked into syncedData when using writeInsert inside onInsert handlers #879
Conversation
…Data when using writeInsert inside onInsert handlers
🦋 Changeset detectedLatest commit: 76f9113 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 85.8 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.34 kB ℹ️ View Unchanged
|
KyleAMathews
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So many caches to mess up! 😆
![]()
Fixes bug where optimistic state Leakes into syncedData when using writeInsert inside onInsert handlers.
Previously, when syncing server-generated fields (like IDs or timestamps) using writeInsert within an onInsert handler, the QueryClient cache was updated with combined visible state (including optimistic changes), which triggered the query observer to write optimistic values back to syncedData.
Now the cache is correctly updated with only server-confirmed state, ensuring syncedData maintains separation from optimistic state.
Fork of the reproduction using preview package from this PR showing it fixed: https://codesandbox.io/p/sandbox/tanstack-db-bug-forked-nqtkvp?file=%2Fsrc%2FApp.tsx
fixes #814
replaces #817