cross-tab-worker-databus 0.20.17 → 0.20.18

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.
@@ -1236,7 +1236,7 @@ var PersistenceRetryCancelledError = class extends Error {
1236
1236
  this.name = "PersistenceRetryCancelledError";
1237
1237
  }
1238
1238
  };
1239
- var CrossTabDataBus = class _CrossTabDataBus {
1239
+ var CrossTabDataBus = class {
1240
1240
  transport;
1241
1241
  cluster;
1242
1242
  // Map of topic → set of local subscribers.
@@ -1300,7 +1300,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1300
1300
  // stop to settle.
1301
1301
  pendingStop = null;
1302
1302
  // Minimum interval in ms between automatic recovery attempts.
1303
- static RECOVERY_COOLDOWN_MS = 1e3;
1303
+ recoveryCooldownMs;
1304
1304
  constructor(options) {
1305
1305
  const replay = options.replay;
1306
1306
  if (replay) {
@@ -1330,7 +1330,11 @@ var CrossTabDataBus = class _CrossTabDataBus {
1330
1330
  if (!Number.isFinite(this.persistenceRetryBackoffMs) || this.persistenceRetryBackoffMs < 0) {
1331
1331
  throw new TypeError("replay.persistenceRetry.backoffMs must be a non-negative finite number.");
1332
1332
  }
1333
- const { autoStart, initialConfig, trace, transport, dedup, ...clusterOptions } = options;
1333
+ const { autoStart, initialConfig, trace, transport, dedup, recovery, ...clusterOptions } = options;
1334
+ this.recoveryCooldownMs = recovery?.cooldownMs ?? 1e3;
1335
+ if (!Number.isFinite(this.recoveryCooldownMs) || this.recoveryCooldownMs <= 0) {
1336
+ throw new TypeError("recovery.cooldownMs must be a positive finite number.");
1337
+ }
1334
1338
  this.now = dedup?.now ?? Date.now;
1335
1339
  this.replayHydration = this.hydrateReplay();
1336
1340
  this.transport = transport;
@@ -1886,7 +1890,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1886
1890
  }
1887
1891
  if (status === "error" && this.started && !this.stopping) {
1888
1892
  const now = this.now();
1889
- if (now - this.lastRecoveryAt >= _CrossTabDataBus.RECOVERY_COOLDOWN_MS) {
1893
+ if (now - this.lastRecoveryAt >= this.recoveryCooldownMs) {
1890
1894
  this.lastRecoveryAt = now;
1891
1895
  const attempt = ++this.recoveryAttempt;
1892
1896
  this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
@@ -1894,7 +1898,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1894
1898
  if (this.stopping || !this.started || this.suspended) return;
1895
1899
  if (this.status !== "error") return;
1896
1900
  void this.reopenTransport(attempt);
1897
- }, _CrossTabDataBus.RECOVERY_COOLDOWN_MS);
1901
+ }, this.recoveryCooldownMs);
1898
1902
  }
1899
1903
  }
1900
1904
  this.invokeHandlers(this.statusHandlers, (handler) => handler(status));