cross-tab-worker-databus 0.21.18 → 0.21.20

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.
@@ -1881,7 +1881,8 @@ var DataBusTraceReporter = class {
1881
1881
  * Record that a message was dispatched on `topic`. Pops the oldest receive
1882
1882
  * timestamp (FIFO) and increments the latency histogram. Dispatches without
1883
1883
  * a matching receive (e.g. broadcast fan-out from another tab) still count
1884
- * as dispatched but do not produce a latency sample.
1884
+ * as dispatched but do not produce a latency sample, and neither does a
1885
+ * dispatch whose delay cannot be computed at all.
1885
1886
  */
1886
1887
  recordDispatched(topic) {
1887
1888
  if (!this.metricsActive) return;
@@ -1891,11 +1892,13 @@ var DataBusTraceReporter = class {
1891
1892
  const receivedTimestamp = queue?.shift();
1892
1893
  if (queue && queue.length === 0) this.receivedAt.delete(topic);
1893
1894
  if (receivedTimestamp === void 0) return;
1895
+ const delayMs = this.now() - receivedTimestamp;
1896
+ if (!Number.isFinite(delayMs)) return;
1894
1897
  this.latencySamples += 1;
1895
- const delayMs = Math.max(0, this.now() - receivedTimestamp);
1896
- const bucketIndex = Math.min(LATENCY_BUCKET_COUNT - 1, Math.floor(delayMs / LATENCY_BUCKET_SIZE_MS));
1898
+ const measuredMs = Math.max(0, delayMs);
1899
+ const bucketIndex = Math.min(LATENCY_BUCKET_COUNT - 1, Math.floor(measuredMs / LATENCY_BUCKET_SIZE_MS));
1897
1900
  this.latencyBuckets[bucketIndex] = (this.latencyBuckets[bucketIndex] ?? 0) + 1;
1898
- this.latencySumMs += delayMs;
1901
+ this.latencySumMs += measuredMs;
1899
1902
  }
1900
1903
  /** Record deduplication outcomes for the next metrics window. */
1901
1904
  recordDedupAccepted() {
@@ -2552,7 +2555,18 @@ var DedupManager = class {
2552
2555
  };
2553
2556
 
2554
2557
  // src/core/version.ts
2555
- var SDK_VERSION = true ? "0.21.18" : "";
2558
+ var SDK_VERSION = (
2559
+ // The `''` arm has zero counts in every coverage run and cannot be lit from a
2560
+ // test: `vitest.config.ts` defines the global for the whole suite, and so does
2561
+ // each bundle `scripts/build.mjs` emits, so reaching this side needs a consumer
2562
+ // that bundles `src/` without passing the define — which is also the only
2563
+ // consumer this module is read by at source level. It cannot be deleted either,
2564
+ // since the declaration's type is `string | undefined` and the export's is
2565
+ // `string` (dropping the conditional is TS2322, measured). Recorded here so the
2566
+ // leg reads as a shape the harness cannot reach rather than as a case nobody
2567
+ // exercised.
2568
+ true ? "0.21.20" : ""
2569
+ );
2556
2570
 
2557
2571
  // src/core/data-bus.ts
2558
2572
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;