cross-tab-worker-databus 0.21.2 → 0.21.4

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.
@@ -614,10 +614,20 @@ function readAllByPrefix(storage, prefix) {
614
614
  return listKeys(storage, prefix).map((key) => ({ key, value: readJson(storage, key) })).filter((entry) => entry.value !== null);
615
615
  }
616
616
 
617
+ // src/utils/error-utils.ts
618
+ function describeFailure(error) {
619
+ try {
620
+ if (error instanceof Error) return error.message;
621
+ return String(error);
622
+ } catch {
623
+ return `[unstringifiable ${typeof error}]`;
624
+ }
625
+ }
626
+
617
627
  // src/utils/validation.ts
618
628
  function assertPositiveSafeInteger(value, name) {
619
629
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
620
- throw new TypeError(`${name} must be a positive safe integer, got ${String(value)}.`);
630
+ throw new TypeError(`${name} must be a positive safe integer, got ${describeFailure(value)}.`);
621
631
  }
622
632
  }
623
633
  function assertPositiveFiniteNumber(value, name) {
@@ -632,7 +642,7 @@ function assertNonNegativeFiniteNumber(value, name) {
632
642
  }
633
643
  function assertPruneStrategy(value) {
634
644
  const allowed = [PRUNE_STRATEGY.COUNT, PRUNE_STRATEGY.AGE, PRUNE_STRATEGY.BOTH];
635
- if (!allowed.includes(String(value))) {
645
+ if (!allowed.includes(describeFailure(value))) {
636
646
  throw new TypeError("pruneStrategy must be count, age, or both.");
637
647
  }
638
648
  }
@@ -2472,7 +2482,7 @@ var DedupManager = class {
2472
2482
  };
2473
2483
 
2474
2484
  // src/core/version.ts
2475
- var SDK_VERSION = true ? "0.21.2" : "";
2485
+ var SDK_VERSION = true ? "0.21.4" : "";
2476
2486
 
2477
2487
  // src/core/data-bus.ts
2478
2488
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
@@ -2781,7 +2791,7 @@ var CrossTabDataBus = class {
2781
2791
  if (this.queuedStart) return this.queuedStart;
2782
2792
  const stop = this.stopPromise ?? Promise.resolve();
2783
2793
  const token = ++this.queuedStartToken;
2784
- const queued = stop.catch(() => void 0).then(() => {
2794
+ const queued = stop.then(() => {
2785
2795
  if (this.queuedStart === queued) this.queuedStart = null;
2786
2796
  if (token <= this.canceledQueuedStartToken) return;
2787
2797
  return this.start(config);
@@ -2863,7 +2873,7 @@ var CrossTabDataBus = class {
2863
2873
  const chainedPendingStop = this.pendingStop;
2864
2874
  const isCurrentLifecycle = () => lifecycleEpoch === this.lifecycleEpoch;
2865
2875
  let startupInProgress = true;
2866
- return before.catch(() => void 0).then(() => {
2876
+ return before.then(() => {
2867
2877
  if (!isCurrentLifecycle() || this.stopping || this.suspended) return;
2868
2878
  if (this.pendingStop === chainedPendingStop) this.pendingStop = null;
2869
2879
  this.transportHasConnected = false;
@@ -3090,7 +3100,7 @@ var CrossTabDataBus = class {
3090
3100
  * the most recent successful open, or `null` until the transport reaches
3091
3101
  * `ready`. */
3092
3102
  getRecoveryStats() {
3093
- const errorMessage = this.lastError instanceof Error ? this.lastError.message : this.lastError === null ? null : String(this.lastError);
3103
+ const errorMessage = this.lastError === null ? null : describeFailure(this.lastError);
3094
3104
  return {
3095
3105
  attempt: this.recoveryAttempt,
3096
3106
  exhausted: this.recoveryExhausted,
@@ -3361,7 +3371,7 @@ var CrossTabDataBus = class {
3361
3371
  }
3362
3372
  this.lastFailure = {
3363
3373
  source,
3364
- message: error instanceof Error ? error.message : String(error),
3374
+ message: describeFailure(error),
3365
3375
  at
3366
3376
  };
3367
3377
  if (source === FAILURE_SOURCE.PERSISTENCE) {