cross-tab-worker-databus 0.21.18 → 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.
@@ -1786,7 +1786,8 @@ var DataBusTraceReporter = class {
1786
1786
  * Record that a message was dispatched on `topic`. Pops the oldest receive
1787
1787
  * timestamp (FIFO) and increments the latency histogram. Dispatches without
1788
1788
  * a matching receive (e.g. broadcast fan-out from another tab) still count
1789
- * as dispatched but do not produce a latency sample.
1789
+ * as dispatched but do not produce a latency sample, and neither does a
1790
+ * dispatch whose delay cannot be computed at all.
1790
1791
  */
1791
1792
  recordDispatched(topic) {
1792
1793
  if (!this.metricsActive) return;
@@ -1796,11 +1797,13 @@ var DataBusTraceReporter = class {
1796
1797
  const receivedTimestamp = queue?.shift();
1797
1798
  if (queue && queue.length === 0) this.receivedAt.delete(topic);
1798
1799
  if (receivedTimestamp === void 0) return;
1800
+ const delayMs = this.now() - receivedTimestamp;
1801
+ if (!Number.isFinite(delayMs)) return;
1799
1802
  this.latencySamples += 1;
1800
- const delayMs = Math.max(0, this.now() - receivedTimestamp);
1801
- const bucketIndex = Math.min(LATENCY_BUCKET_COUNT - 1, Math.floor(delayMs / LATENCY_BUCKET_SIZE_MS));
1803
+ const measuredMs = Math.max(0, delayMs);
1804
+ const bucketIndex = Math.min(LATENCY_BUCKET_COUNT - 1, Math.floor(measuredMs / LATENCY_BUCKET_SIZE_MS));
1802
1805
  this.latencyBuckets[bucketIndex] = (this.latencyBuckets[bucketIndex] ?? 0) + 1;
1803
- this.latencySumMs += delayMs;
1806
+ this.latencySumMs += measuredMs;
1804
1807
  }
1805
1808
  /** Record deduplication outcomes for the next metrics window. */
1806
1809
  recordDedupAccepted() {
@@ -2457,7 +2460,18 @@ var DedupManager = class {
2457
2460
  };
2458
2461
 
2459
2462
  // src/core/version.ts
2460
- var SDK_VERSION = true ? "0.21.18" : "";
2463
+ var SDK_VERSION = (
2464
+ // The `''` arm has zero counts in every coverage run and cannot be lit from a
2465
+ // test: `vitest.config.ts` defines the global for the whole suite, and so does
2466
+ // each bundle `scripts/build.mjs` emits, so reaching this side needs a consumer
2467
+ // that bundles `src/` without passing the define — which is also the only
2468
+ // consumer this module is read by at source level. It cannot be deleted either,
2469
+ // since the declaration's type is `string | undefined` and the export's is
2470
+ // `string` (dropping the conditional is TS2322, measured). Recorded here so the
2471
+ // leg reads as a shape the harness cannot reach rather than as a case nobody
2472
+ // exercised.
2473
+ true ? "0.21.19" : ""
2474
+ );
2461
2475
 
2462
2476
  // src/core/data-bus.ts
2463
2477
  var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
@@ -3688,4 +3702,4 @@ export {
3688
3702
  parseDataBusPublication,
3689
3703
  selectWorkerBackend
3690
3704
  };
3691
- //# sourceMappingURL=chunk-KRSD6KHE.js.map
3705
+ //# sourceMappingURL=chunk-Q2INCAFO.js.map