@instantdb/core 0.22.104 → 0.22.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/core",
3
- "version": "0.22.104",
3
+ "version": "0.22.105",
4
4
  "description": "Instant's core local abstraction",
5
5
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/core",
6
6
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "dependencies": {
54
54
  "mutative": "^1.0.10",
55
55
  "uuid": "^11.1.0",
56
- "@instantdb/version": "0.22.104"
56
+ "@instantdb/version": "0.22.105"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest",
package/src/Reactor.js CHANGED
@@ -1498,10 +1498,18 @@ export default class Reactor {
1498
1498
  this._trySendAuthed(eventId, { op: 'add-query', q });
1499
1499
  });
1500
1500
 
1501
- const muts = this._rewriteMutationsSorted(
1501
+ const rewrittenMutations = this._rewriteMutations(
1502
1502
  this.ensureAttrs(),
1503
1503
  this._pendingMutations(),
1504
1504
  );
1505
+ if (rewrittenMutations !== this._pendingMutations()) {
1506
+ // Persist rewritten mutations to avoid stale attr ids in future txs.
1507
+ this.kv.updateInPlace((prev) => {
1508
+ prev.pendingMutations = rewrittenMutations;
1509
+ });
1510
+ }
1511
+
1512
+ const muts = sortedMutationEntries(rewrittenMutations.entries());
1505
1513
  muts.forEach(([eventId, mut]) => {
1506
1514
  if (!mut['tx-id']) {
1507
1515
  this._sendMutation(eventId, mut);