cross-tab-worker-databus 0.21.17 → 0.21.19

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.
@@ -1915,7 +1915,8 @@ var DataBusTraceReporter = class {
1915
1915
  * Record that a message was dispatched on `topic`. Pops the oldest receive
1916
1916
  * timestamp (FIFO) and increments the latency histogram. Dispatches without
1917
1917
  * a matching receive (e.g. broadcast fan-out from another tab) still count
1918
- * as dispatched but do not produce a latency sample.
1918
+ * as dispatched but do not produce a latency sample, and neither does a
1919
+ * dispatch whose delay cannot be computed at all.
1919
1920
  */
1920
1921
  recordDispatched(topic) {
1921
1922
  if (!this.metricsActive) return;
@@ -1925,11 +1926,13 @@ var DataBusTraceReporter = class {
1925
1926
  const receivedTimestamp = queue?.shift();
1926
1927
  if (queue && queue.length === 0) this.receivedAt.delete(topic);
1927
1928
  if (receivedTimestamp === void 0) return;
1929
+ const delayMs = this.now() - receivedTimestamp;
1930
+ if (!Number.isFinite(delayMs)) return;
1928
1931
  this.latencySamples += 1;
1929
- const delayMs = Math.max(0, this.now() - receivedTimestamp);
1930
- const bucketIndex = Math.min(LATENCY_BUCKET_COUNT - 1, Math.floor(delayMs / LATENCY_BUCKET_SIZE_MS));
1932
+ const measuredMs = Math.max(0, delayMs);
1933
+ const bucketIndex = Math.min(LATENCY_BUCKET_COUNT - 1, Math.floor(measuredMs / LATENCY_BUCKET_SIZE_MS));
1931
1934
  this.latencyBuckets[bucketIndex] = (this.latencyBuckets[bucketIndex] ?? 0) + 1;
1932
- this.latencySumMs += delayMs;
1935
+ this.latencySumMs += measuredMs;
1933
1936
  }
1934
1937
  /** Record deduplication outcomes for the next metrics window. */
1935
1938
  recordDedupAccepted() {
@@ -2586,7 +2589,18 @@ var DedupManager = class {
2586
2589
  };
2587
2590
 
2588
2591
  // src/core/version.ts
2589
- var SDK_VERSION = true ? "0.21.17" : "";
2592
+ var SDK_VERSION = (
2593
+ // The `''` arm has zero counts in every coverage run and cannot be lit from a
2594
+ // test: `vitest.config.ts` defines the global for the whole suite, and so does
2595
+ // each bundle `scripts/build.mjs` emits, so reaching this side needs a consumer
2596
+ // that bundles `src/` without passing the define — which is also the only
2597
+ // consumer this module is read by at source level. It cannot be deleted either,
2598
+ // since the declaration's type is `string | undefined` and the export's is
2599
+ // `string` (dropping the conditional is TS2322, measured). Recorded here so the
2600
+ // leg reads as a shape the harness cannot reach rather than as a case nobody
2601
+ // exercised.
2602
+ true ? "0.21.19" : ""
2603
+ );
2590
2604
 
2591
2605
  // src/core/data-bus.ts
2592
2606
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;