cross-tab-worker-databus 0.20.58 → 0.20.59

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.
@@ -1332,6 +1332,13 @@ var CrossTabDataBus = class {
1332
1332
  // a transport reopen succeeds so traces can correlate repeated failures.
1333
1333
  recoveryAttempt = 0;
1334
1334
  recoveryExhausted = false;
1335
+ /** Monotonic generation incremented on every successful transport open.
1336
+ * Stays in lockstep with `lastSuccessAt` so callers can detect that the
1337
+ * transport has been reopened even if the timestamp window is short. */
1338
+ recoveryGeneration = 0;
1339
+ /** Timestamp of the most recent successful transport open. Null until the
1340
+ * transport has reached the `ready` state at least once. */
1341
+ lastSuccessAt = null;
1335
1342
  // True while the tab is hidden so an in-flight transport start does not mark
1336
1343
  // the transport ready after suspendTransport() has stopped it.
1337
1344
  suspended = false;
@@ -1525,7 +1532,11 @@ var CrossTabDataBus = class {
1525
1532
  if (this.status === "error") {
1526
1533
  throw new Error("Transport failed during startup.");
1527
1534
  }
1528
- if (!this.suspended && !this.stopping) this.transportReady = true;
1535
+ if (!this.suspended && !this.stopping) {
1536
+ this.recoveryGeneration += 1;
1537
+ this.lastSuccessAt = this.now();
1538
+ this.transportReady = true;
1539
+ }
1529
1540
  });
1530
1541
  }).catch((error) => {
1531
1542
  if (stopClusterOnFailure) this.started = false;
@@ -1695,9 +1706,22 @@ var CrossTabDataBus = class {
1695
1706
  return this.status;
1696
1707
  }
1697
1708
  /** Return the current automatic transport recovery state. `hasError` means a transport error is currently retained. */
1709
+ /** Return the current automatic transport recovery state plus diagnostics.
1710
+ * `generation` increments on every successful transport open (initial start
1711
+ * and every recovery); `lastSuccessAt` is the timestamp of the most recent
1712
+ * successful open, or `null` until the transport reaches `ready`. */
1698
1713
  getRecoveryStats() {
1699
1714
  const errorMessage = this.lastError instanceof Error ? this.lastError.message : this.lastError === null ? null : String(this.lastError);
1700
- return { attempt: this.recoveryAttempt, exhausted: this.recoveryExhausted, maxAttempts: this.recoveryMaxAttempts, hasError: this.lastError !== null, errorMessage, errorAt: this.lastErrorAt };
1715
+ return {
1716
+ attempt: this.recoveryAttempt,
1717
+ exhausted: this.recoveryExhausted,
1718
+ maxAttempts: this.recoveryMaxAttempts,
1719
+ hasError: this.lastError !== null,
1720
+ errorMessage,
1721
+ errorAt: this.lastErrorAt,
1722
+ generation: this.recoveryGeneration,
1723
+ lastSuccessAt: this.lastSuccessAt
1724
+ };
1701
1725
  }
1702
1726
  /** Snapshot of the cluster state (workers, routes, assignments).
1703
1727
  * For diagnostics only — the returned object is a shallow copy but