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.
@@ -1288,6 +1288,9 @@ var CrossTabDataBus = class _CrossTabDataBus {
1288
1288
  // Timestamp of the last automatic transport recovery attempt.
1289
1289
  // Used to avoid a tight retry loop when the transport fails repeatedly.
1290
1290
  lastRecoveryAt = 0;
1291
+ // Monotonic attempt number within one runtime recovery sequence; reset once
1292
+ // a transport reopen succeeds so traces can correlate repeated failures.
1293
+ recoveryAttempt = 0;
1291
1294
  // True while the tab is hidden so an in-flight transport start does not mark
1292
1295
  // the transport ready after suspendTransport() has stopped it.
1293
1296
  suspended = false;
@@ -1885,11 +1888,12 @@ var CrossTabDataBus = class _CrossTabDataBus {
1885
1888
  const now = this.now();
1886
1889
  if (now - this.lastRecoveryAt >= _CrossTabDataBus.RECOVERY_COOLDOWN_MS) {
1887
1890
  this.lastRecoveryAt = now;
1888
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "scheduled" });
1891
+ const attempt = ++this.recoveryAttempt;
1892
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
1889
1893
  setTimeout(() => {
1890
1894
  if (this.stopping || !this.started || this.suspended) return;
1891
1895
  if (this.status !== "error") return;
1892
- void this.reopenTransport();
1896
+ void this.reopenTransport(attempt);
1893
1897
  }, _CrossTabDataBus.RECOVERY_COOLDOWN_MS);
1894
1898
  }
1895
1899
  }
@@ -1980,10 +1984,11 @@ var CrossTabDataBus = class _CrossTabDataBus {
1980
1984
  * its rejection so the reopen is not blocked. Returns the opening promise so
1981
1985
  * callers can queue operations behind it.
1982
1986
  */
1983
- reopenTransport() {
1987
+ reopenTransport(recoveryAttempt) {
1984
1988
  if (this.stopping || this.activeConfig === void 0) return Promise.resolve();
1985
1989
  if (this.startPromise && this.startPromise !== this.pendingStop) return this.startPromise;
1986
1990
  const config = this.activeConfig;
1991
+ const traceAttempt = recoveryAttempt ?? (this.recoveryAttempt > 0 ? this.recoveryAttempt : void 0);
1987
1992
  this.started = true;
1988
1993
  this.suspended = false;
1989
1994
  this.updateStatus("connecting");
@@ -1992,11 +1997,16 @@ var CrossTabDataBus = class _CrossTabDataBus {
1992
1997
  this.startPromise = opening;
1993
1998
  void opening.then(
1994
1999
  () => {
1995
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "succeeded" });
2000
+ if (traceAttempt !== void 0) {
2001
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: traceAttempt, outcome: "succeeded" });
2002
+ this.recoveryAttempt = 0;
2003
+ }
1996
2004
  if (this.startPromise === opening) this.startPromise = null;
1997
2005
  },
1998
2006
  () => {
1999
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "failed" });
2007
+ if (traceAttempt !== void 0) {
2008
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: traceAttempt, outcome: "failed" });
2009
+ }
2000
2010
  }
2001
2011
  );
2002
2012
  void opening.catch(() => void 0);