ahmed-rivet-convex 2.2.8 → 2.2.9

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.
@@ -4679,6 +4679,32 @@ async function persistDD31(lc, clientID, memdag, perdag, mutators, closed, forma
4679
4679
  );
4680
4680
  }
4681
4681
  }
4682
+ if (!memdagBaseSnapshotPersisted) {
4683
+ const latestBase = await baseSnapshotFromCommit(
4684
+ latestPerdagMainClientGroupHeadCommit,
4685
+ perdagWrite
4686
+ );
4687
+ assertSnapshotCommitDD31(latestBase);
4688
+ if (compareCookiesForSnapshots(memdagBaseSnapshot, latestBase) <= 0 && (memdagBaseSnapshot.meta.lastMutationIDs[clientID] ?? 0) > await latestPerdagMainClientGroupHeadCommit.getMutationID(
4689
+ clientID,
4690
+ perdagWrite
4691
+ )) {
4692
+ lc.debug?.(
4693
+ "persist deferred: perdag head trails this client's confirmed LMID",
4694
+ {
4695
+ clientID,
4696
+ memdagLMID: memdagBaseSnapshot.meta.lastMutationIDs[clientID],
4697
+ perdagHeadLMID: await latestPerdagMainClientGroupHeadCommit.getMutationID(
4698
+ clientID,
4699
+ perdagWrite
4700
+ ),
4701
+ memdagCookie: memdagBaseSnapshot.meta.cookieJSON,
4702
+ perdagCookie: latestBase.meta.cookieJSON
4703
+ }
4704
+ );
4705
+ return;
4706
+ }
4707
+ }
4682
4708
  let zeroDataForPerdagHeadCommit;
4683
4709
  if (!memdagBaseSnapshotPersisted && getZeroData) {
4684
4710
  if (newMainClientGroupHeadHash !== perdagHeadHashAtRead) {
@@ -4823,7 +4849,9 @@ async function refresh(lc, memdag, perdag, clientID, mutators, diffConfig, close
4823
4849
  if (shouldAbortRefresh(
4824
4850
  memdagBaseSnapshot,
4825
4851
  perdagClientGroupBaseSnapshot2,
4826
- perdagClientGroupHeadHash2
4852
+ perdagClientGroupHeadHash2,
4853
+ perdagLmid2,
4854
+ clientID
4827
4855
  )) {
4828
4856
  return void 0;
4829
4857
  }
@@ -4881,7 +4909,9 @@ async function refresh(lc, memdag, perdag, clientID, mutators, diffConfig, close
4881
4909
  if (shouldAbortRefresh(
4882
4910
  memdagBaseSnapshot2,
4883
4911
  perdagClientGroupBaseSnapshot,
4884
- perdagClientGroupHeadHash
4912
+ perdagClientGroupHeadHash,
4913
+ perdagLmid,
4914
+ clientID
4885
4915
  )) {
4886
4916
  return {
4887
4917
  type: "aborted",
@@ -4962,12 +4992,12 @@ async function refresh(lc, memdag, perdag, clientID, mutators, diffConfig, close
4962
4992
  diffs: result.diffs
4963
4993
  };
4964
4994
  }
4965
- function shouldAbortRefresh(memdagBaseSnapshot, perdagClientGroupBaseSnapshot, perdagClientGroupHeadHash) {
4995
+ function shouldAbortRefresh(memdagBaseSnapshot, perdagClientGroupBaseSnapshot, perdagClientGroupHeadHash, perdagLmid, clientID) {
4966
4996
  const baseSnapshotCookieCompareResult = compareCookiesForSnapshots(
4967
4997
  memdagBaseSnapshot,
4968
4998
  perdagClientGroupBaseSnapshot
4969
4999
  );
4970
- return baseSnapshotCookieCompareResult > 0 || baseSnapshotCookieCompareResult === 0 && perdagClientGroupHeadHash === perdagClientGroupBaseSnapshot.chunk.hash;
5000
+ return baseSnapshotCookieCompareResult > 0 || (memdagBaseSnapshot.meta.lastMutationIDs[clientID] ?? 0) > perdagLmid || baseSnapshotCookieCompareResult === 0 && perdagClientGroupHeadHash === perdagClientGroupBaseSnapshot.chunk.hash;
4971
5001
  }
4972
5002
 
4973
5003
  // ../replicache/src/process-scheduler.ts
@@ -6058,6 +6088,7 @@ var ReplicacheImpl = class {
6058
6088
  resolve();
6059
6089
  }
6060
6090
  async maybeEndPull(syncHead, requestID) {
6091
+ let chunkRetries = 0;
6061
6092
  for (; ; ) {
6062
6093
  if (this.#closed) {
6063
6094
  return;
@@ -6079,7 +6110,17 @@ var ReplicacheImpl = class {
6079
6110
  void this.#schedulePersist();
6080
6111
  return;
6081
6112
  }
6082
- const zeroData2 = await this.#zero?.getTxData?.(syncHead);
6113
+ let zeroData2;
6114
+ try {
6115
+ zeroData2 = await this.#zero?.getTxData?.(syncHead);
6116
+ } catch (e) {
6117
+ if (e instanceof ChunkNotFoundError && ++chunkRetries <= 3) {
6118
+ lc.debug?.("IVM base moved during replay; retrying", e.message);
6119
+ await Promise.resolve();
6120
+ continue;
6121
+ }
6122
+ throw e;
6123
+ }
6083
6124
  for (const mutation of replayMutations) {
6084
6125
  if (this.#subscriptions.hasPendingSubscriptionRuns) {
6085
6126
  await Promise.resolve();
@@ -15611,7 +15652,7 @@ function makeMessage(message, context, logLevel) {
15611
15652
  }
15612
15653
 
15613
15654
  // ../zero-client/src/client/version.ts
15614
- var version2 = "2.2.8";
15655
+ var version2 = "2.2.9";
15615
15656
 
15616
15657
  // ../zero-client/src/client/log-options.ts
15617
15658
  var LevelFilterLogSink = class {
package/dist/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Zero
3
- } from "./chunk-H4HI57GK.js";
3
+ } from "./chunk-LTAG2LCD.js";
4
4
  import {
5
5
  DEFAULT_TTL_MS
6
6
  } from "./chunk-FVFX5V7B.js";
package/dist/zero.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  number,
7
7
  string,
8
8
  table
9
- } from "./chunk-H4HI57GK.js";
9
+ } from "./chunk-LTAG2LCD.js";
10
10
  import "./chunk-FVFX5V7B.js";
11
11
 
12
12
  // src/adapters/convex.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ahmed-rivet-convex",
3
- "version": "2.2.8",
3
+ "version": "2.2.9",
4
4
  "description": "Client-only local-first data runtime for the browser: reactive queries over IndexedDB with optimistic writes.",
5
5
  "author": "Ahmed Banihani",
6
6
  "license": "Apache-2.0",