@vue-skuilder/db 0.2.37 → 0.3.1

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 (47) hide show
  1. package/dist/{contentSource-D_E7JaxR.d.ts → contentSource-2zVmcjKA.d.ts} +6 -1
  2. package/dist/core/index.cjs +155 -100
  3. package/dist/core/index.cjs.map +1 -1
  4. package/dist/core/index.d.ts +5 -5
  5. package/dist/core/navigators/Pipeline.mjs +8 -0
  6. package/dist/core/navigators/Pipeline.mjs.map +1 -1
  7. package/dist/core/versionStamps.mjs +1 -1
  8. package/dist/{dataLayerProvider-BDshhSp_.d.ts → dataLayerProvider-rGyLQ93v.d.ts} +1 -1
  9. package/dist/diagnostics/index.d.ts +3 -3
  10. package/dist/impl/common/BaseUserDB.mjs +61 -34
  11. package/dist/impl/common/BaseUserDB.mjs.map +1 -1
  12. package/dist/impl/couch/CourseSyncService.mjs +23 -1
  13. package/dist/impl/couch/CourseSyncService.mjs.map +1 -1
  14. package/dist/impl/couch/courseDB.mjs +4 -0
  15. package/dist/impl/couch/courseDB.mjs.map +1 -1
  16. package/dist/impl/couch/index.cjs +177 -101
  17. package/dist/impl/couch/index.cjs.map +1 -1
  18. package/dist/impl/couch/index.d.ts +5 -3
  19. package/dist/impl/couch/updateQueue.mjs +69 -46
  20. package/dist/impl/couch/updateQueue.mjs.map +1 -1
  21. package/dist/impl/static/index.cjs +151 -100
  22. package/dist/impl/static/index.cjs.map +1 -1
  23. package/dist/impl/static/index.d.ts +4 -4
  24. package/dist/{index-BLDpFYG3.d.ts → index-C745YB_6.d.ts} +1 -1
  25. package/dist/index.cjs +187 -102
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +23 -10
  28. package/dist/index.mjs +2 -1
  29. package/dist/study/SessionController.mjs +4 -0
  30. package/dist/study/SessionController.mjs.map +1 -1
  31. package/dist/{types-DChCz22D.d.ts → types-DF0JuPbs.d.ts} +1 -1
  32. package/dist/{types-legacy-fT5Y1Wuy.d.ts → types-legacy-DdVjg81H.d.ts} +1 -1
  33. package/dist/util/packer/index.d.ts +3 -3
  34. package/dist/util/perfMarks.mjs +30 -0
  35. package/dist/util/perfMarks.mjs.map +1 -0
  36. package/docs/session-lifecycle-and-replan.md +71 -58
  37. package/package.json +3 -3
  38. package/src/core/interfaces/courseDB.ts +6 -0
  39. package/src/core/navigators/Pipeline.ts +8 -0
  40. package/src/impl/common/BaseUserDB.ts +74 -46
  41. package/src/impl/couch/CourseSyncService.ts +19 -2
  42. package/src/impl/couch/courseDB.ts +5 -0
  43. package/src/impl/couch/updateQueue.ts +86 -82
  44. package/src/study/SessionController.ts +4 -0
  45. package/src/util/index.ts +1 -0
  46. package/src/util/perfMarks.ts +35 -0
  47. package/tests/impl/updateQueue.test.ts +57 -0
@@ -1472,8 +1472,10 @@ var init_updateQueue = __esm({
1472
1472
  init_logger();
1473
1473
  UpdateQueue = class extends Loggable {
1474
1474
  _className = "UpdateQueue";
1475
- pendingUpdates = {};
1476
- inprogressUpdates = {};
1475
+ /** Updates not yet taken by a write, per doc. */
1476
+ pending = /* @__PURE__ */ new Map();
1477
+ /** Docs with a drain loop running. */
1478
+ draining = /* @__PURE__ */ new Set();
1477
1479
  readDB;
1478
1480
  // Database for read operations
1479
1481
  writeDB;
@@ -1491,6 +1493,9 @@ var init_updateQueue = __esm({
1491
1493
  * **Error Handling Pattern:**
1492
1494
  * - This method does NOT create documents if they don't exist
1493
1495
  * - Callers are responsible for handling 404 errors and creating documents
1496
+ * - A rejected update is dropped from the queue: a caller that creates the
1497
+ * doc after a 404 has already applied its change and must not see it
1498
+ * re-applied by a later update to the same doc
1494
1499
  * - This design maintains separation of concerns (UpdateQueue handles conflicts, callers handle lifecycle)
1495
1500
  *
1496
1501
  * @example
@@ -1507,12 +1512,16 @@ var init_updateQueue = __esm({
1507
1512
  */
1508
1513
  update(id, update) {
1509
1514
  logger.debug(`Update requested on doc: ${id}`);
1510
- if (this.pendingUpdates[id]) {
1511
- this.pendingUpdates[id].push(update);
1512
- } else {
1513
- this.pendingUpdates[id] = [update];
1514
- }
1515
- return this.applyUpdates(id);
1515
+ return new Promise((resolve, reject) => {
1516
+ const queue = this.pending.get(id) ?? [];
1517
+ queue.push({
1518
+ update,
1519
+ resolve,
1520
+ reject
1521
+ });
1522
+ this.pending.set(id, queue);
1523
+ if (!this.draining.has(id)) void this.drain(id);
1524
+ });
1516
1525
  }
1517
1526
  constructor(readDB, writeDB) {
1518
1527
  super();
@@ -1523,64 +1532,56 @@ var init_updateQueue = __esm({
1523
1532
  logger.debug(`db info: ${JSON.stringify(i)}`);
1524
1533
  });
1525
1534
  }
1526
- async applyUpdates(id) {
1527
- logger.debug(`Applying updates on doc: ${id}`);
1528
- if (this.inprogressUpdates[id]) {
1529
- while (this.inprogressUpdates[id]) {
1530
- await new Promise((resolve) => setTimeout(resolve, Math.random() * 50));
1535
+ /** Writes the doc's queued updates, batch by batch, until none are left. */
1536
+ async drain(id) {
1537
+ this.draining.add(id);
1538
+ try {
1539
+ let batch;
1540
+ while ((batch = this.pending.get(id)) && batch.length > 0) {
1541
+ this.pending.delete(id);
1542
+ try {
1543
+ const doc = await this.write(
1544
+ id,
1545
+ batch.map((p) => p.update)
1546
+ );
1547
+ batch.forEach((p) => p.resolve(doc));
1548
+ } catch (e) {
1549
+ batch.forEach((p) => p.reject(e));
1550
+ }
1531
1551
  }
1532
- return this.applyUpdates(id);
1533
- } else {
1534
- if (this.pendingUpdates[id] && this.pendingUpdates[id].length > 0) {
1535
- this.inprogressUpdates[id] = true;
1536
- const MAX_RETRIES = 5;
1537
- for (let i = 0; i < MAX_RETRIES; i++) {
1538
- try {
1539
- const doc = await this.readDB.get(id);
1540
- let updatedDoc = { ...doc };
1541
- const updatesToApply = [...this.pendingUpdates[id]];
1542
- for (const update of updatesToApply) {
1543
- if (typeof update === "function") {
1544
- updatedDoc = { ...updatedDoc, ...update(updatedDoc) };
1545
- } else {
1546
- updatedDoc = {
1547
- ...updatedDoc,
1548
- ...update
1549
- };
1550
- }
1551
- }
1552
- await this.writeDB.put(updatedDoc);
1553
- this.pendingUpdates[id].splice(0, updatesToApply.length);
1554
- if (this.pendingUpdates[id].length === 0) {
1555
- this.inprogressUpdates[id] = false;
1556
- delete this.inprogressUpdates[id];
1557
- } else {
1558
- return this.applyUpdates(id);
1559
- }
1560
- return updatedDoc;
1561
- } catch (e) {
1562
- if (e.name === "conflict" && i < MAX_RETRIES - 1) {
1563
- logger.warn(`Conflict on update for doc ${id}, retry #${i + 1}`);
1564
- await new Promise((res) => setTimeout(res, 50 * Math.random()));
1565
- } else if (e.name === "not_found" && i === 0) {
1566
- logger.warn(`Update failed for ${id} - does not exist. Throwing to caller.`);
1567
- delete this.inprogressUpdates[id];
1568
- throw e;
1569
- } else {
1570
- delete this.inprogressUpdates[id];
1571
- if (this.pendingUpdates[id]) {
1572
- delete this.pendingUpdates[id];
1573
- }
1574
- logger.error(`Error on attemped update (retry ${i}): ${JSON.stringify(e)}`);
1575
- throw e;
1576
- }
1577
- }
1552
+ } finally {
1553
+ this.draining.delete(id);
1554
+ }
1555
+ }
1556
+ /** One read-apply-put of `updates`, retried on conflict against a fresh read. */
1557
+ async write(id, updates) {
1558
+ logger.debug(`Applying ${updates.length} update(s) on doc: ${id}`);
1559
+ const MAX_RETRIES = 5;
1560
+ for (let i = 0; i < MAX_RETRIES; i++) {
1561
+ try {
1562
+ const doc = await this.readDB.get(id);
1563
+ let updatedDoc = {
1564
+ ...doc
1565
+ };
1566
+ for (const update of updates) {
1567
+ updatedDoc = typeof update === "function" ? { ...updatedDoc, ...update(updatedDoc) } : { ...updatedDoc, ...update };
1568
+ }
1569
+ const res = await this.writeDB.put(updatedDoc);
1570
+ return { ...updatedDoc, _rev: res.rev };
1571
+ } catch (e) {
1572
+ if (e.name === "conflict" && i < MAX_RETRIES - 1) {
1573
+ logger.warn(`Conflict on update for doc ${id}, retry #${i + 1}`);
1574
+ await new Promise((res) => setTimeout(res, 50 * Math.random()));
1575
+ } else if (e.name === "not_found" && i === 0) {
1576
+ logger.warn(`Update failed for ${id} - does not exist. Throwing to caller.`);
1577
+ throw e;
1578
+ } else {
1579
+ logger.error(`Error on attemped update (retry ${i}): ${JSON.stringify(e)}`);
1580
+ throw e;
1578
1581
  }
1579
- throw new Error(`UpdateQueue failed for doc ${id} after ${MAX_RETRIES} retries.`);
1580
- } else {
1581
- throw new Error(`Empty Updates Queue Triggered`);
1582
1582
  }
1583
1583
  }
1584
+ throw new Error(`UpdateQueue failed for doc ${id} after ${MAX_RETRIES} retries.`);
1584
1585
  }
1585
1586
  };
1586
1587
  }
@@ -1885,6 +1886,29 @@ var init_dataDirectory = __esm({
1885
1886
  }
1886
1887
  });
1887
1888
 
1889
+ // src/util/perfMarks.ts
1890
+ function perfMark(name, detail) {
1891
+ try {
1892
+ globalThis.performance?.mark(name, detail ? { detail } : void 0);
1893
+ } catch {
1894
+ }
1895
+ }
1896
+ function perfMeasure(name, start, end, detail) {
1897
+ try {
1898
+ globalThis.performance?.measure(name, {
1899
+ start,
1900
+ ...end !== void 0 ? { end } : {},
1901
+ ...detail ? { detail } : {}
1902
+ });
1903
+ } catch {
1904
+ }
1905
+ }
1906
+ var init_perfMarks = __esm({
1907
+ "src/util/perfMarks.ts"() {
1908
+ "use strict";
1909
+ }
1910
+ });
1911
+
1888
1912
  // src/core/navigators/regulators.ts
1889
1913
  function clamp01(x) {
1890
1914
  return Math.min(1, Math.max(0, x));
@@ -2099,6 +2123,7 @@ var init_Pipeline = __esm({
2099
2123
  import_common3 = require("@vue-skuilder/common");
2100
2124
  init_navigators();
2101
2125
  init_logger();
2126
+ init_perfMarks();
2102
2127
  init_orchestration();
2103
2128
  init_PipelineDebugger();
2104
2129
  init_diversityRerank();
@@ -2302,6 +2327,13 @@ var init_Pipeline = __esm({
2302
2327
  logger.info(
2303
2328
  `[Pipeline:timing] total=${(tFilter - t0).toFixed(0)}ms (context=${(tContext - t0).toFixed(0)} generate=${(tGenerate - tContext).toFixed(0)} hydrate=${(tHydrate - tGenerate).toFixed(0)} filter=${(tFilter - tHydrate).toFixed(0)})`
2304
2329
  );
2330
+ perfMeasure("sk:pipeline-run", t0, tFilter, {
2331
+ context: Math.round(tContext - t0),
2332
+ generate: Math.round(tGenerate - tContext),
2333
+ hydrate: Math.round(tHydrate - tGenerate),
2334
+ filter: Math.round(tFilter - tHydrate),
2335
+ binding: this.course?.readsLocal === void 0 ? "unknown" : this.course.readsLocal ? "local" : "remote"
2336
+ });
2305
2337
  const topScores = result.slice(0, 3).map((c) => c.score);
2306
2338
  logExecutionSummary(
2307
2339
  this.generator.name,
@@ -4258,6 +4290,9 @@ var init_BaseUserDB = __esm({
4258
4290
  // Database to use for write operations (local-first approach)
4259
4291
  updateQueue;
4260
4292
  _hydration = { state: "not-required" };
4293
+ /** See scanScheduledCards. Bumped by every write to scheduled reviews. */
4294
+ _scheduledScan = null;
4295
+ _scheduledGeneration = 0;
4261
4296
  /** In-flight hydration, so concurrent callers can wait for a real answer. */
4262
4297
  _hydrationPromise = null;
4263
4298
  /**
@@ -4502,18 +4537,38 @@ Currently logged-in as ${this._username}.`
4502
4537
  *
4503
4538
  */
4504
4539
  async getActiveCards() {
4540
+ return (await this.scanScheduledCards()).map((doc) => ({
4541
+ courseID: doc.courseId,
4542
+ cardID: doc.cardId
4543
+ }));
4544
+ }
4545
+ /**
4546
+ * The user's scheduled reviews (`card_review_*`), all of them: one `allDocs`
4547
+ * scan shared by concurrent readers. A pipeline run's generators start
4548
+ * together (`CompositeGenerator`), and each used to scan the range itself
4549
+ * (`getActiveCards` from ELO and Prescribed, `getReviewstoDate` from SRS).
4550
+ * Sharing only an in-flight scan keeps reads as fresh as before; a schedule
4551
+ * or removal of a review starts a new scan for anyone reading after it.
4552
+ * Docs are shared between callers: copy before mutating.
4553
+ */
4554
+ scanScheduledCards() {
4555
+ const inFlight = this._scheduledScan;
4556
+ if (inFlight && inFlight.generation === this._scheduledGeneration) return inFlight.scan;
4505
4557
  const keys = getStartAndEndKeys(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */]);
4506
- const reviews = await this.remoteDB.allDocs({
4507
- startkey: keys.startkey,
4508
- endkey: keys.endkey,
4509
- include_docs: true
4510
- });
4511
- return reviews.rows.map((r) => {
4512
- return {
4513
- courseID: r.doc.courseId,
4514
- cardID: r.doc.cardId
4515
- };
4516
- });
4558
+ const entry = {
4559
+ generation: this._scheduledGeneration,
4560
+ scan: this.remoteDB.allDocs({
4561
+ startkey: keys.startkey,
4562
+ endkey: keys.endkey,
4563
+ include_docs: true
4564
+ }).then((res) => res.rows.map((row) => row.doc))
4565
+ };
4566
+ this._scheduledScan = entry;
4567
+ const done = () => {
4568
+ if (this._scheduledScan === entry) this._scheduledScan = null;
4569
+ };
4570
+ entry.scan.then(done, done);
4571
+ return entry.scan;
4517
4572
  }
4518
4573
  async getActivityRecords() {
4519
4574
  try {
@@ -4579,28 +4634,23 @@ Currently logged-in as ${this._username}.`
4579
4634
  }
4580
4635
  }
4581
4636
  async getReviewstoDate(targetDate, course_id) {
4582
- const keys = getStartAndEndKeys(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */]);
4583
- const reviews = await this.remoteDB.allDocs({
4584
- startkey: keys.startkey,
4585
- endkey: keys.endkey,
4586
- include_docs: true
4587
- });
4637
+ const reviews = await this.scanScheduledCards();
4588
4638
  log3(
4589
4639
  `Fetching ${this._username}'s scheduled reviews${course_id ? ` for course ${course_id}` : ""}.`
4590
4640
  );
4591
- return reviews.rows.filter((r) => {
4592
- if (r.id.startsWith(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */])) {
4641
+ return reviews.filter((doc) => {
4642
+ if (doc._id.startsWith(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */])) {
4593
4643
  const date = import_moment5.default.utc(
4594
- r.id.substr(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */].length),
4644
+ doc._id.substr(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */].length),
4595
4645
  REVIEW_TIME_FORMAT
4596
4646
  );
4597
4647
  if (targetDate.isAfter(date)) {
4598
- if (course_id === void 0 || r.doc.courseId === course_id) {
4648
+ if (course_id === void 0 || doc.courseId === course_id) {
4599
4649
  return true;
4600
4650
  }
4601
4651
  }
4602
4652
  }
4603
- }).map((r) => r.doc);
4653
+ }).map((doc) => ({ ...doc }));
4604
4654
  }
4605
4655
  async getReviewsForcast(daysCount, course_id) {
4606
4656
  const time = import_moment5.default.utc().add(daysCount, "days");
@@ -4984,22 +5034,20 @@ Currently logged-in as ${this._username}.`
4984
5034
  async putCardRecord(record) {
4985
5035
  const cardHistoryID = getCardHistoryID(record.courseID, record.cardID);
4986
5036
  record.timeStamp = import_moment5.default.utc(record.timeStamp).toString();
4987
- try {
4988
- const cardHistory = await this.update(
4989
- cardHistoryID,
4990
- function(h) {
4991
- h.records.push(record);
4992
- h.bestInterval = h.bestInterval || 0;
4993
- if (areQuestionRecords(h)) {
4994
- h.lapses = getLapses(h.records);
4995
- h.streak = getStreak(h.records);
4996
- } else {
4997
- h.lapses = h.lapses || 0;
4998
- h.streak = h.streak || 0;
4999
- }
5000
- return h;
5001
- }
5002
- );
5037
+ const append = (h) => {
5038
+ h.records.push(record);
5039
+ h.bestInterval = h.bestInterval || 0;
5040
+ if (areQuestionRecords(h)) {
5041
+ h.lapses = getLapses(h.records);
5042
+ h.streak = getStreak(h.records);
5043
+ } else {
5044
+ h.lapses = h.lapses || 0;
5045
+ h.streak = h.streak || 0;
5046
+ }
5047
+ return h;
5048
+ };
5049
+ const appendToExisting = async () => {
5050
+ const cardHistory = await this.update(cardHistoryID, append);
5003
5051
  cardHistory.records = cardHistory.records.map((record2) => {
5004
5052
  const ret = {
5005
5053
  ...record2
@@ -5008,6 +5056,9 @@ Currently logged-in as ${this._username}.`
5008
5056
  return ret;
5009
5057
  });
5010
5058
  return cardHistory;
5059
+ };
5060
+ try {
5061
+ return await appendToExisting();
5011
5062
  } catch (e) {
5012
5063
  const reason = e;
5013
5064
  if (reason.status === 404) {
@@ -5024,6 +5075,9 @@ Currently logged-in as ${this._username}.`
5024
5075
  const putResult = await this.writeDB.put(initCardHistory);
5025
5076
  return { ...initCardHistory, _rev: putResult.rev };
5026
5077
  } catch (creationError) {
5078
+ if (creationError.name === "conflict") {
5079
+ return appendToExisting();
5080
+ }
5027
5081
  throw new Error(
5028
5082
  `Failed to create CardHistory for ${cardHistoryID}. Reason: ${creationError}`
5029
5083
  );
@@ -5067,6 +5121,7 @@ Currently logged-in as ${this._username}.`
5067
5121
  const deletePromises = duplicateDocIds.map(async (docId) => {
5068
5122
  try {
5069
5123
  const doc = await this.remoteDB.get(docId);
5124
+ this._scheduledGeneration++;
5070
5125
  await this.writeDB.remove(doc);
5071
5126
  log3(`Successfully removed duplicate review: ${docId}`);
5072
5127
  } catch (error) {
@@ -5212,9 +5267,11 @@ Currently logged-in as ${this._username}.`
5212
5267
  }
5213
5268
  }
5214
5269
  async scheduleCardReview(review) {
5270
+ this._scheduledGeneration++;
5215
5271
  return scheduleCardReviewLocal(this.writeDB, review);
5216
5272
  }
5217
5273
  async removeScheduledCardReview(reviewId) {
5274
+ this._scheduledGeneration++;
5218
5275
  return removeScheduledCardReviewLocal(this.writeDB, reviewId);
5219
5276
  }
5220
5277
  async registerForClassroom(_classId, _registerAs) {
@@ -6836,6 +6893,10 @@ var init_courseDB2 = __esm({
6836
6893
  * values may be stale, so read-modify-write cycles must go through
6837
6894
  * the remote DB to avoid conflicts).
6838
6895
  */
6896
+ /** Reads go to this device's replica (perf marks report it as the session's binding). */
6897
+ get readsLocal() {
6898
+ return this.db !== this.remoteDB;
6899
+ }
6839
6900
  constructor(id, userLookup, localDB) {
6840
6901
  this.id = id;
6841
6902
  const remote = getCourseDB(this.id);
@@ -7862,6 +7923,7 @@ var init_CourseSyncService = __esm({
7862
7923
  init_pouchdb_setup();
7863
7924
  init_couch();
7864
7925
  init_logger();
7926
+ init_perfMarks();
7865
7927
  SYNC_MARKER_ID = "_local/sk-course-sync-complete";
7866
7928
  DEFAULT_REPLICATION = {
7867
7929
  batchSize: 1e3,
@@ -7960,6 +8022,7 @@ var init_CourseSyncService = __esm({
7960
8022
  entry.localDB = localDB;
7961
8023
  entry.status = { state: "ready" };
7962
8024
  entry.readyPromise = null;
8025
+ perfMark("sk:course-sync-ready", { courseId, from: "marker" });
7963
8026
  logger.info(
7964
8027
  `[CourseSyncService] Using this device's replica of course ${courseId}; refreshing in the background`
7965
8028
  );
@@ -8002,6 +8065,12 @@ var init_CourseSyncService = __esm({
8002
8065
  syncTimeMs,
8003
8066
  viewWarmTimeMs
8004
8067
  };
8068
+ perfMark("sk:course-sync-refreshed", {
8069
+ courseId,
8070
+ docs: result.docs_written,
8071
+ syncTimeMs,
8072
+ viewWarmTimeMs
8073
+ });
8005
8074
  logger.info(
8006
8075
  `[CourseSyncService] Background refresh of course ${courseId}: ${result.docs_written} docs in ${syncTimeMs}ms, views ${viewWarmTimeMs}ms`
8007
8076
  );
@@ -8102,6 +8171,11 @@ var init_CourseSyncService = __esm({
8102
8171
  );
8103
8172
  const result = await this.replicate(remoteDB, localDB);
8104
8173
  const syncTimeMs = Date.now() - syncStart;
8174
+ perfMark("sk:course-sync-replicated", {
8175
+ courseId,
8176
+ docs: result.docs_written,
8177
+ ms: syncTimeMs
8178
+ });
8105
8179
  logger.info(
8106
8180
  `[CourseSyncService] Replication complete for course ${courseId}: ${result.docs_written} docs in ${syncTimeMs}ms`
8107
8181
  );
@@ -8119,6 +8193,7 @@ var init_CourseSyncService = __esm({
8119
8193
  syncTimeMs,
8120
8194
  viewWarmTimeMs
8121
8195
  };
8196
+ perfMark("sk:course-sync-ready", { courseId, from: "sync", viewWarmTimeMs });
8122
8197
  } catch (e) {
8123
8198
  const errorMsg = e instanceof Error ? e.message : String(e);
8124
8199
  logger.error(
@@ -8206,7 +8281,8 @@ var init_CourseSyncService = __esm({
8206
8281
  try {
8207
8282
  localEpoch = await localDB.get("db-epoch");
8208
8283
  } catch {
8209
- return true;
8284
+ const info = await localDB.info();
8285
+ return info.doc_count > 0 || !!info.update_seq;
8210
8286
  }
8211
8287
  return remoteEpoch.epoch !== localEpoch.epoch;
8212
8288
  } catch {