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.
@@ -1313,6 +1313,9 @@ var CrossTabDataBus = class _CrossTabDataBus {
1313
1313
  // Timestamp of the last automatic transport recovery attempt.
1314
1314
  // Used to avoid a tight retry loop when the transport fails repeatedly.
1315
1315
  lastRecoveryAt = 0;
1316
+ // Monotonic attempt number within one runtime recovery sequence; reset once
1317
+ // a transport reopen succeeds so traces can correlate repeated failures.
1318
+ recoveryAttempt = 0;
1316
1319
  // True while the tab is hidden so an in-flight transport start does not mark
1317
1320
  // the transport ready after suspendTransport() has stopped it.
1318
1321
  suspended = false;
@@ -1910,11 +1913,12 @@ var CrossTabDataBus = class _CrossTabDataBus {
1910
1913
  const now = this.now();
1911
1914
  if (now - this.lastRecoveryAt >= _CrossTabDataBus.RECOVERY_COOLDOWN_MS) {
1912
1915
  this.lastRecoveryAt = now;
1913
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "scheduled" });
1916
+ const attempt = ++this.recoveryAttempt;
1917
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt, outcome: "scheduled" });
1914
1918
  setTimeout(() => {
1915
1919
  if (this.stopping || !this.started || this.suspended) return;
1916
1920
  if (this.status !== "error") return;
1917
- void this.reopenTransport();
1921
+ void this.reopenTransport(attempt);
1918
1922
  }, _CrossTabDataBus.RECOVERY_COOLDOWN_MS);
1919
1923
  }
1920
1924
  }
@@ -2005,10 +2009,11 @@ var CrossTabDataBus = class _CrossTabDataBus {
2005
2009
  * its rejection so the reopen is not blocked. Returns the opening promise so
2006
2010
  * callers can queue operations behind it.
2007
2011
  */
2008
- reopenTransport() {
2012
+ reopenTransport(recoveryAttempt) {
2009
2013
  if (this.stopping || this.activeConfig === void 0) return Promise.resolve();
2010
2014
  if (this.startPromise && this.startPromise !== this.pendingStop) return this.startPromise;
2011
2015
  const config = this.activeConfig;
2016
+ const traceAttempt = recoveryAttempt ?? (this.recoveryAttempt > 0 ? this.recoveryAttempt : void 0);
2012
2017
  this.started = true;
2013
2018
  this.suspended = false;
2014
2019
  this.updateStatus("connecting");
@@ -2017,11 +2022,16 @@ var CrossTabDataBus = class _CrossTabDataBus {
2017
2022
  this.startPromise = opening;
2018
2023
  void opening.then(
2019
2024
  () => {
2020
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "succeeded" });
2025
+ if (traceAttempt !== void 0) {
2026
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: traceAttempt, outcome: "succeeded" });
2027
+ this.recoveryAttempt = 0;
2028
+ }
2021
2029
  if (this.startPromise === opening) this.startPromise = null;
2022
2030
  },
2023
2031
  () => {
2024
- this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: 1, outcome: "failed" });
2032
+ if (traceAttempt !== void 0) {
2033
+ this.trace.event({ type: "reliability", operation: "transport_recovery", attempt: traceAttempt, outcome: "failed" });
2034
+ }
2025
2035
  }
2026
2036
  );
2027
2037
  void opening.catch(() => void 0);