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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  本项目遵循 [Semantic Versioning](https://semver.org/);变更记录格式参考 [Keep a Changelog](https://keepachangelog.com/)。
4
4
 
5
+ ## [0.20.18] - 2026-09-03
6
+
7
+ ### Added
8
+
9
+ - Added optional `recovery.cooldownMs` to tune automatic transport reopen pacing for different runtime environments.
10
+ - Added validation and fake-timer coverage for custom recovery cooldowns.
11
+
5
12
  ## [0.20.17] - 2026-09-03
6
13
 
7
14
  ### Added
@@ -2,7 +2,7 @@ import {
2
2
  CrossTabDataBus,
3
3
  parseDataBusPublication,
4
4
  selectWorkerBackend
5
- } from "./chunk-LZ7S62BQ.js";
5
+ } from "./chunk-UN5Q6JUA.js";
6
6
 
7
7
  // src/centrifuge-session.ts
8
8
  import { Centrifuge } from "centrifuge";
@@ -1220,7 +1220,7 @@ var PersistenceRetryCancelledError = class extends Error {
1220
1220
  this.name = "PersistenceRetryCancelledError";
1221
1221
  }
1222
1222
  };
1223
- var CrossTabDataBus = class _CrossTabDataBus {
1223
+ var CrossTabDataBus = class {
1224
1224
  transport;
1225
1225
  cluster;
1226
1226
  // Map of topic → set of local subscribers.
@@ -1284,7 +1284,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1284
1284
  // stop to settle.
1285
1285
  pendingStop = null;
1286
1286
  // Minimum interval in ms between automatic recovery attempts.
1287
- static RECOVERY_COOLDOWN_MS = 1e3;
1287
+ recoveryCooldownMs;
1288
1288
  constructor(options) {
1289
1289
  const replay = options.replay;
1290
1290
  if (replay) {
@@ -1314,7 +1314,11 @@ var CrossTabDataBus = class _CrossTabDataBus {
1314
1314
  if (!Number.isFinite(this.persistenceRetryBackoffMs) || this.persistenceRetryBackoffMs < 0) {
1315
1315
  throw new TypeError("replay.persistenceRetry.backoffMs must be a non-negative finite number.");
1316
1316
  }
1317
- const { autoStart, initialConfig, trace, transport, dedup, ...clusterOptions } = options;
1317
+ const { autoStart, initialConfig, trace, transport, dedup, recovery, ...clusterOptions } = options;
1318
+ this.recoveryCooldownMs = recovery?.cooldownMs ?? 1e3;
1319
+ if (!Number.isFinite(this.recoveryCooldownMs) || this.recoveryCooldownMs <= 0) {
1320
+ throw new TypeError("recovery.cooldownMs must be a positive finite number.");
1321
+ }
1318
1322
  this.now = dedup?.now ?? Date.now;
1319
1323
  this.replayHydration = this.hydrateReplay();
1320
1324
  this.transport = transport;
@@ -1870,7 +1874,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1870
1874
  }
1871
1875
  if (status === "error" && this.started && !this.stopping) {
1872
1876
  const now = this.now();
1873
- if (now - this.lastRecoveryAt >= _CrossTabDataBus.RECOVERY_COOLDOWN_MS) {
1877
+ if (now - this.lastRecoveryAt >= this.recoveryCooldownMs) {
1874
1878
  this.lastRecoveryAt = now;
1875
1879
  const attempt = ++this.recoveryAttempt;
1876
1880
  this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
@@ -1878,7 +1882,7 @@ var CrossTabDataBus = class _CrossTabDataBus {
1878
1882
  if (this.stopping || !this.started || this.suspended) return;
1879
1883
  if (this.status !== "error") return;
1880
1884
  void this.reopenTransport(attempt);
1881
- }, _CrossTabDataBus.RECOVERY_COOLDOWN_MS);
1885
+ }, this.recoveryCooldownMs);
1882
1886
  }
1883
1887
  }
1884
1888
  this.invokeHandlers(this.statusHandlers, (handler) => handler(status));
@@ -2091,4 +2095,4 @@ export {
2091
2095
  parseDataBusPublication,
2092
2096
  selectWorkerBackend
2093
2097
  };
2094
- //# sourceMappingURL=chunk-LZ7S62BQ.js.map
2098
+ //# sourceMappingURL=chunk-UN5Q6JUA.js.map