cross-tab-worker-databus 0.20.18 → 0.20.20

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.
@@ -1301,6 +1301,7 @@ var CrossTabDataBus = class {
1301
1301
  pendingStop = null;
1302
1302
  // Minimum interval in ms between automatic recovery attempts.
1303
1303
  recoveryCooldownMs;
1304
+ recoveryMaxAttempts;
1304
1305
  constructor(options) {
1305
1306
  const replay = options.replay;
1306
1307
  if (replay) {
@@ -1332,9 +1333,13 @@ var CrossTabDataBus = class {
1332
1333
  }
1333
1334
  const { autoStart, initialConfig, trace, transport, dedup, recovery, ...clusterOptions } = options;
1334
1335
  this.recoveryCooldownMs = recovery?.cooldownMs ?? 1e3;
1336
+ this.recoveryMaxAttempts = recovery?.maxAttempts ?? Number.POSITIVE_INFINITY;
1335
1337
  if (!Number.isFinite(this.recoveryCooldownMs) || this.recoveryCooldownMs <= 0) {
1336
1338
  throw new TypeError("recovery.cooldownMs must be a positive finite number.");
1337
1339
  }
1340
+ if (!(this.recoveryMaxAttempts === Number.POSITIVE_INFINITY || Number.isSafeInteger(this.recoveryMaxAttempts) && this.recoveryMaxAttempts > 0)) {
1341
+ throw new TypeError("recovery.maxAttempts must be a positive safe integer.");
1342
+ }
1338
1343
  this.now = dedup?.now ?? Date.now;
1339
1344
  this.replayHydration = this.hydrateReplay();
1340
1345
  this.transport = transport;
@@ -1893,6 +1898,10 @@ var CrossTabDataBus = class {
1893
1898
  if (now - this.lastRecoveryAt >= this.recoveryCooldownMs) {
1894
1899
  this.lastRecoveryAt = now;
1895
1900
  const attempt = ++this.recoveryAttempt;
1901
+ if (attempt > this.recoveryMaxAttempts) {
1902
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: this.recoveryMaxAttempts, outcome: "exhausted" });
1903
+ return;
1904
+ }
1896
1905
  this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
1897
1906
  setTimeout(() => {
1898
1907
  if (this.stopping || !this.started || this.suspended) return;