cross-tab-worker-databus 0.20.65 → 0.20.67

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.
@@ -356,6 +356,8 @@ var WorkerClusterRuntime = class {
356
356
  routeOwnerCacheMax;
357
357
  routeOwnerCacheHits = 0;
358
358
  routeOwnerCacheMisses = 0;
359
+ unknownMessageCount = 0;
360
+ lastUnknownMessageType = null;
359
361
  touchRouteOwnerCache(topicKey, value) {
360
362
  if (this.routeOwnerCache.has(topicKey)) this.routeOwnerCache.delete(topicKey);
361
363
  this.routeOwnerCache.set(topicKey, value);
@@ -712,6 +714,10 @@ var WorkerClusterRuntime = class {
712
714
  }
713
715
  return false;
714
716
  }
717
+ /** Count and last type of unknown protocol messages observed. */
718
+ getUnknownMessageStats() {
719
+ return { count: this.unknownMessageCount, lastType: this.lastUnknownMessageType };
720
+ }
715
721
  /** Read-only snapshot of the cluster state (workers, routes, assignments). */
716
722
  getSnapshot() {
717
723
  const routes = this.storage ? readAllByPrefix(this.storage, this.routePrefix).map(({ value }) => ({
@@ -775,9 +781,13 @@ var WorkerClusterRuntime = class {
775
781
  case "REGISTRY":
776
782
  this.reconcile();
777
783
  return;
778
- default:
784
+ default: {
785
+ this.unknownMessageCount += 1;
786
+ const unknown = message;
787
+ this.lastUnknownMessageType = typeof unknown.type === "string" ? unknown.type : null;
779
788
  this.handlers.onUnknownMessage?.(message);
780
789
  return;
790
+ }
781
791
  }
782
792
  };
783
793
  /** Handle a point-to-point CONTROL message (SUBSCRIBE / UNSUBSCRIBE / PUBLISH). */
@@ -1883,6 +1893,7 @@ var CrossTabDataBus = class {
1883
1893
  recovery: this.getRecoveryStats(),
1884
1894
  dedup: this.getDedupStats(),
1885
1895
  replay: { enabled: Boolean(this.replayBuffers), topics: this.replayBuffers?.size ?? 0, messages },
1896
+ protocol: { unknownMessages: this.cluster.getUnknownMessageStats().count, lastUnknownMessageType: this.cluster.getUnknownMessageStats().lastType },
1886
1897
  cluster: this.cluster.getSnapshot()
1887
1898
  };
1888
1899
  }