cross-tab-worker-databus 0.21.3 → 0.21.5

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
  }
@@ -1256,6 +1266,7 @@ var WorkerClusterRuntime = class {
1256
1266
  /** Handle a point-to-point CONTROL message (SUBSCRIBE / UNSUBSCRIBE / PUBLISH). */
1257
1267
  handleControlMessage(message) {
1258
1268
  if (message.targetWorkerId !== this.workerId) return;
1269
+ if (message.topicKey !== void 0 && createOpaqueKey(message.topic) !== message.topicKey) return;
1259
1270
  this.rememberTopic(message.topic);
1260
1271
  switch (message.action) {
1261
1272
  case CONTROL_ACTION.SUBSCRIBE: {
@@ -2472,7 +2483,7 @@ var DedupManager = class {
2472
2483
  };
2473
2484
 
2474
2485
  // src/core/version.ts
2475
- var SDK_VERSION = true ? "0.21.3" : "";
2486
+ var SDK_VERSION = true ? "0.21.5" : "";
2476
2487
 
2477
2488
  // src/core/data-bus.ts
2478
2489
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
@@ -3090,7 +3101,7 @@ var CrossTabDataBus = class {
3090
3101
  * the most recent successful open, or `null` until the transport reaches
3091
3102
  * `ready`. */
3092
3103
  getRecoveryStats() {
3093
- const errorMessage = this.lastError instanceof Error ? this.lastError.message : this.lastError === null ? null : String(this.lastError);
3104
+ const errorMessage = this.lastError === null ? null : describeFailure(this.lastError);
3094
3105
  return {
3095
3106
  attempt: this.recoveryAttempt,
3096
3107
  exhausted: this.recoveryExhausted,
@@ -3361,7 +3372,7 @@ var CrossTabDataBus = class {
3361
3372
  }
3362
3373
  this.lastFailure = {
3363
3374
  source,
3364
- message: error instanceof Error ? error.message : String(error),
3375
+ message: describeFailure(error),
3365
3376
  at
3366
3377
  };
3367
3378
  if (source === FAILURE_SOURCE.PERSISTENCE) {
@@ -3532,7 +3543,6 @@ var CrossTabDataBus = class {
3532
3543
  }
3533
3544
  }
3534
3545
  );
3535
- void opening.catch(() => void 0);
3536
3546
  return opening;
3537
3547
  }
3538
3548
  /**