@pylonsync/sync 0.3.359 → 0.3.360

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +13 -6
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.359",
6
+ "version": "0.3.360",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -1524,14 +1524,21 @@ export class SyncEngine {
1524
1524
  ): Promise<void> {
1525
1525
  const wipeMutations = opts.wipeMutations === true;
1526
1526
  this.cursor = { last_seq: 0 };
1527
- this.store.clearAll();
1528
- // The replica was just wiped and will re-pull from 0 (org switch, identity
1529
- // flip, or a 410 cursor reset). Re-enter "loading" until that re-pull lands
1530
- // rows — otherwise switching to another org flashes an empty list for the
1531
- // seconds the snapshot takes. Re-arm the fallback so it can't pin; the
1532
- // arriving rows (populated org) or the deadline (empty org) re-settle it.
1527
+ // The replica is about to be wiped and will re-pull from 0 (org switch,
1528
+ // identity flip, or a 410 cursor reset). Re-enter "loading" until that
1529
+ // re-pull lands rows — otherwise switching to another org flashes an empty
1530
+ // list for the seconds the snapshot takes. Re-arm the fallback so it can't
1531
+ // pin; the arriving rows (populated org) or the deadline (empty org)
1532
+ // re-settle it.
1533
+ //
1534
+ // ORDER MATTERS: this must precede `clearAll()`. `clearAll()` is the only
1535
+ // notify on this path, and it used to run FIRST — so every subscriber
1536
+ // re-read the signal while it was still `true`, and the flip to `false` on
1537
+ // the next line reached nobody. The documented protection above silently
1538
+ // did nothing: an org switch dropped straight to the new org's empty list.
1533
1539
  this._initialSyncSettled = false;
1534
1540
  this.armInitialSyncFallback();
1541
+ this.store.clearAll();
1535
1542
  // Disk is about to be wiped + re-pulled from 0, so any prior
1536
1543
  // persist degradation is moot — start the durability invariant
1537
1544
  // fresh. (If the fresh snapshot also fails to persist, enqueueApply