cross-tab-worker-databus 0.20.18 → 0.20.19

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.
@@ -1326,6 +1326,7 @@ var CrossTabDataBus = class {
1326
1326
  pendingStop = null;
1327
1327
  // Minimum interval in ms between automatic recovery attempts.
1328
1328
  recoveryCooldownMs;
1329
+ recoveryMaxAttempts;
1329
1330
  constructor(options) {
1330
1331
  const replay = options.replay;
1331
1332
  if (replay) {
@@ -1357,9 +1358,13 @@ var CrossTabDataBus = class {
1357
1358
  }
1358
1359
  const { autoStart, initialConfig, trace, transport, dedup, recovery, ...clusterOptions } = options;
1359
1360
  this.recoveryCooldownMs = recovery?.cooldownMs ?? 1e3;
1361
+ this.recoveryMaxAttempts = recovery?.maxAttempts ?? Number.POSITIVE_INFINITY;
1360
1362
  if (!Number.isFinite(this.recoveryCooldownMs) || this.recoveryCooldownMs <= 0) {
1361
1363
  throw new TypeError("recovery.cooldownMs must be a positive finite number.");
1362
1364
  }
1365
+ if (!(this.recoveryMaxAttempts === Number.POSITIVE_INFINITY || Number.isSafeInteger(this.recoveryMaxAttempts) && this.recoveryMaxAttempts > 0)) {
1366
+ throw new TypeError("recovery.maxAttempts must be a positive safe integer.");
1367
+ }
1363
1368
  this.now = dedup?.now ?? Date.now;
1364
1369
  this.replayHydration = this.hydrateReplay();
1365
1370
  this.transport = transport;
@@ -1918,6 +1923,7 @@ var CrossTabDataBus = class {
1918
1923
  if (now - this.lastRecoveryAt >= this.recoveryCooldownMs) {
1919
1924
  this.lastRecoveryAt = now;
1920
1925
  const attempt = ++this.recoveryAttempt;
1926
+ if (attempt > this.recoveryMaxAttempts) return;
1921
1927
  this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
1922
1928
  setTimeout(() => {
1923
1929
  if (this.stopping || !this.started || this.suspended) return;