cross-tab-worker-databus 0.21.20 → 0.21.22

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.
@@ -1735,10 +1735,11 @@ var DataBusTraceReporter = class {
1735
1735
  }
1736
1736
  /** Synchronous snapshot of the current metrics window without resetting it.
1737
1737
  * Returns the same derived counters as a periodic `message_metrics` event,
1738
- * or null when metrics recording is inactive (disabled or events-only mode).
1739
- * The window keeps accumulating until the next interval flush. */
1738
+ * or null when metrics recording is inactive, which covers each of disabled,
1739
+ * stopped and events-only mode. The window keeps accumulating until the next
1740
+ * interval flush. */
1740
1741
  getMetrics() {
1741
- if (!this.metricsActive || this.stopped) return null;
1742
+ if (!this.metricsActive) return null;
1742
1743
  const timestamp = this.now();
1743
1744
  const samples = this.latencySamples;
1744
1745
  return {
@@ -1814,15 +1815,28 @@ var DataBusTraceReporter = class {
1814
1815
  }
1815
1816
  /** True when metrics recording is active: enabled, not stopped, and the mode
1816
1817
  * includes metrics. Extracted so the seven readers — `getMetrics`, the five
1817
- * `record*` methods and `flush` — share one guard instead of repeating it.
1818
- * The `!stopped` term is part of the contract, not a bonus: `event()` does not
1819
- * go through this getter and gates on `stopped` itself. */
1818
+ * `record*` methods and `flush` — share one guard instead of repeating it, which
1819
+ * leaves `stopped` read in exactly two places: this term, and `event()`, which
1820
+ * skips metrics entirely and so gates on the field itself.
1821
+ *
1822
+ * Do not add a `|| this.stopped` back at a call site. `getMetrics` and `flush`
1823
+ * each carried one, and the repetition is what made this term look untestable:
1824
+ * deleting the term left all 37 test files green, because a read of a field the
1825
+ * guard consulted one expression earlier can never be the decider. With both
1826
+ * repeats gone the same deletion dies twice in `tests/trace.test.ts` — to
1827
+ * "starts a fresh metrics window after pause and resume, and stop prevents later
1828
+ * flushes", and to "getMetrics returns null while metrics recording is inactive",
1829
+ * whose name promises all three inactive cases and which tested two of them until
1830
+ * this file stopped absorbing the third. What the term holds: `stop()` resets the
1831
+ * counters through `pause()` before any later call can reach them, so without it a
1832
+ * `record*` during a stopped window accumulates unreset and `start()` — which
1833
+ * clears `stopped` without resetting — hands it to the new session's window. */
1820
1834
  get metricsActive() {
1821
1835
  return this.enabled && !this.stopped && this.mode !== TRACE_MODE.EVENTS;
1822
1836
  }
1823
1837
  /** Emit the accumulated metrics snapshot if the interval is active. */
1824
1838
  flush() {
1825
- if (!this.metricsActive || this.stopped) return;
1839
+ if (!this.metricsActive) return;
1826
1840
  this.flushNow();
1827
1841
  }
1828
1842
  flushNow() {
@@ -2463,14 +2477,14 @@ var DedupManager = class {
2463
2477
  var SDK_VERSION = (
2464
2478
  // The `''` arm has zero counts in every coverage run and cannot be lit from a
2465
2479
  // 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.20" : ""
2480
+ // each bundle `scripts/build.mjs` emits, so reaching this side needs a tool that
2481
+ // consumes `src/` without passing the define — and this repository has none. The
2482
+ // two source-level readers are named in the header above, and only one of them
2483
+ // evaluates this expression. It cannot be deleted either, since the
2484
+ // declaration's type is `string | undefined` and the export's is `string`
2485
+ // (dropping the conditional is TS2322, measured). Recorded here so the leg reads
2486
+ // as a shape the harness cannot reach rather than as a case nobody exercised.
2487
+ true ? "0.21.22" : ""
2474
2488
  );
2475
2489
 
2476
2490
  // src/core/data-bus.ts
@@ -3406,8 +3420,10 @@ var CrossTabDataBus = class {
3406
3420
  * wrong mechanism and was the shipped claim until it was measured: a snapshot
3407
3421
  * taken with the opening still unresolved already listed the route, its
3408
3422
  * confirmation and both tabs' worker records, because
3409
- * `BatchingStorageWriter` serves pending writes on read (`storage-batch.ts:79-82`
3410
- * for `getItem`, `:143-155` for the `keys()` union that `readAllByPrefix` uses). */
3423
+ * `BatchingStorageWriter` serves pending writes on read — `getItem` returns the
3424
+ * pending value before touching the store, and the private `keys()` union of
3425
+ * persisted keys, pending writes minus pending deletes is what `readAllByPrefix`
3426
+ * walks. */
3411
3427
  emitCoordinationTrace() {
3412
3428
  const snapshot = this.cluster.getSnapshot();
3413
3429
  this.trace.event({
@@ -3702,4 +3718,4 @@ export {
3702
3718
  parseDataBusPublication,
3703
3719
  selectWorkerBackend
3704
3720
  };
3705
- //# sourceMappingURL=chunk-VQZXIMXR.js.map
3721
+ //# sourceMappingURL=chunk-ISYP7LVP.js.map