cross-tab-worker-databus 0.20.16 → 0.20.17

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.17] - 2026-09-03
6
+
7
+ ### Added
8
+
9
+ - Consecutive transport recovery traces now carry monotonic attempt numbers and reset after a successful reopen.
10
+ - Added regression coverage for multi-failure recovery sequences.
11
+
5
12
  ## [0.20.16] - 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-WSJN2RG7.js";
5
+ } from "./chunk-LZ7S62BQ.js";
6
6
 
7
7
  // src/centrifuge-session.ts
8
8
  import { Centrifuge } from "centrifuge";
@@ -1272,6 +1272,9 @@ var CrossTabDataBus = class _CrossTabDataBus {
1272
1272
  // Timestamp of the last automatic transport recovery attempt.
1273
1273
  // Used to avoid a tight retry loop when the transport fails repeatedly.
1274
1274
  lastRecoveryAt = 0;
1275
+ // Monotonic attempt number within one runtime recovery sequence; reset once
1276
+ // a transport reopen succeeds so traces can correlate repeated failures.
1277
+ recoveryAttempt = 0;
1275
1278
  // True while the tab is hidden so an in-flight transport start does not mark
1276
1279
  // the transport ready after suspendTransport() has stopped it.
1277
1280
  suspended = false;
@@ -1869,11 +1872,12 @@ var CrossTabDataBus = class _CrossTabDataBus {
1869
1872
  const now = this.now();
1870
1873
  if (now - this.lastRecoveryAt >= _CrossTabDataBus.RECOVERY_COOLDOWN_MS) {
1871
1874
  this.lastRecoveryAt = now;
1872
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "scheduled" });
1875
+ const attempt = ++this.recoveryAttempt;
1876
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
1873
1877
  setTimeout(() => {
1874
1878
  if (this.stopping || !this.started || this.suspended) return;
1875
1879
  if (this.status !== "error") return;
1876
- void this.reopenTransport();
1880
+ void this.reopenTransport(attempt);
1877
1881
  }, _CrossTabDataBus.RECOVERY_COOLDOWN_MS);
1878
1882
  }
1879
1883
  }
@@ -1964,10 +1968,11 @@ var CrossTabDataBus = class _CrossTabDataBus {
1964
1968
  * its rejection so the reopen is not blocked. Returns the opening promise so
1965
1969
  * callers can queue operations behind it.
1966
1970
  */
1967
- reopenTransport() {
1971
+ reopenTransport(recoveryAttempt) {
1968
1972
  if (this.stopping || this.activeConfig === void 0) return Promise.resolve();
1969
1973
  if (this.startPromise && this.startPromise !== this.pendingStop) return this.startPromise;
1970
1974
  const config = this.activeConfig;
1975
+ const traceAttempt = recoveryAttempt ?? (this.recoveryAttempt > 0 ? this.recoveryAttempt : void 0);
1971
1976
  this.started = true;
1972
1977
  this.suspended = false;
1973
1978
  this.updateStatus("connecting");
@@ -1976,11 +1981,16 @@ var CrossTabDataBus = class _CrossTabDataBus {
1976
1981
  this.startPromise = opening;
1977
1982
  void opening.then(
1978
1983
  () => {
1979
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "succeeded" });
1984
+ if (traceAttempt !== void 0) {
1985
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: traceAttempt, outcome: "succeeded" });
1986
+ this.recoveryAttempt = 0;
1987
+ }
1980
1988
  if (this.startPromise === opening) this.startPromise = null;
1981
1989
  },
1982
1990
  () => {
1983
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "failed" });
1991
+ if (traceAttempt !== void 0) {
1992
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: traceAttempt, outcome: "failed" });
1993
+ }
1984
1994
  }
1985
1995
  );
1986
1996
  void opening.catch(() => void 0);
@@ -2081,4 +2091,4 @@ export {
2081
2091
  parseDataBusPublication,
2082
2092
  selectWorkerBackend
2083
2093
  };
2084
- //# sourceMappingURL=chunk-WSJN2RG7.js.map
2094
+ //# sourceMappingURL=chunk-LZ7S62BQ.js.map