@pylonsync/sync 0.3.162 → 0.3.165

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 +9 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.162",
6
+ "version": "0.3.165",
7
7
  "type": "module",
8
8
  "main": "src/index.ts",
9
9
  "types": "src/index.ts",
package/src/index.ts CHANGED
@@ -1746,12 +1746,20 @@ export class SyncEngine {
1746
1746
  };
1747
1747
  const tenantNow = next.tenantId;
1748
1748
  // First observation seeds lastSeenTenant without a reset — we have
1749
- // nothing to invalidate yet. Subsequent changes flip the replica.
1749
+ // nothing to invalidate yet. Subsequent changes flip the replica
1750
+ // AND immediately re-pull so subscribers see the new tenant's
1751
+ // rows. Without the re-pull, resetReplica() leaves the store
1752
+ // empty until the next periodic poll, and `db.useQuery` returns
1753
+ // [] for the entire interval — exactly the "I switched orgs
1754
+ // but the dashboard is empty" symptom the cloud team reported.
1755
+ // The 410 RESYNC_REQUIRED path (see ~line 1499) does the same
1756
+ // dance for the same reason.
1750
1757
  if (
1751
1758
  this.lastSeenTenant !== undefined &&
1752
1759
  this.lastSeenTenant !== tenantNow
1753
1760
  ) {
1754
1761
  await this.resetReplica();
1762
+ await this.pull();
1755
1763
  }
1756
1764
  this.lastSeenTenant = tenantNow;
1757
1765
  const prev = this._resolvedSession;