@actuallab/rpc 12.3.81 → 12.3.85

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.
package/dist/index.cjs CHANGED
@@ -1483,6 +1483,7 @@ var RpcStream = class _RpcStream {
1483
1483
  _started = false;
1484
1484
  _iterating = false;
1485
1485
  _ackSentUpTo = 0;
1486
+ _nextConsumedIndex = 0;
1486
1487
  constructor(sourceOrRef, optionsOrPeer) {
1487
1488
  if (_isStreamSource(sourceOrRef)) {
1488
1489
  const options = optionsOrPeer ?? {};
@@ -1574,12 +1575,11 @@ var RpcStream = class _RpcStream {
1574
1575
  return;
1575
1576
  }
1576
1577
  if (index < this._nextExpectedIndex) {
1577
- this._maybeSendAck(index + 1);
1578
+ this._maybeSendAck(Math.min(index + 1, this._nextConsumedIndex));
1578
1579
  return;
1579
1580
  }
1580
1581
  this._buffer.push(item);
1581
1582
  this._nextExpectedIndex = index + 1;
1582
- this._maybeSendAck(this._nextExpectedIndex);
1583
1583
  this._notifyConsumer();
1584
1584
  }
1585
1585
  /** Called by system call handler when a batch arrives ($sys.B). */
@@ -1599,12 +1599,11 @@ var RpcStream = class _RpcStream {
1599
1599
  return;
1600
1600
  }
1601
1601
  if (index < this._nextExpectedIndex) {
1602
- this._maybeSendAck(index + items.length);
1602
+ this._maybeSendAck(Math.min(index + items.length, this._nextConsumedIndex));
1603
1603
  return;
1604
1604
  }
1605
1605
  for (const item of items) this._buffer.push(item);
1606
1606
  this._nextExpectedIndex = index + items.length;
1607
- this._maybeSendAck(this._nextExpectedIndex);
1608
1607
  this._notifyConsumer();
1609
1608
  }
1610
1609
  /** Called by system call handler when the stream ends ($sys.End). */
@@ -1648,9 +1647,11 @@ var RpcStream = class _RpcStream {
1648
1647
  this._started = true;
1649
1648
  this._sendAck(0, true);
1650
1649
  }
1650
+ this._maybeSendAck(this._nextConsumedIndex);
1651
1651
  for (; ; ) {
1652
1652
  if (!this._buffer.isEmpty()) {
1653
1653
  const value = this._buffer.shift();
1654
+ this._nextConsumedIndex++;
1654
1655
  return { value, done: false };
1655
1656
  }
1656
1657
  if (this._completed) {
@@ -2293,6 +2294,17 @@ var defaultConnectionUrlResolver = (peer) => {
2293
2294
  return peer.ref + sep + `clientId=${peer.clientId}&f=${formatKey}`;
2294
2295
  }
2295
2296
  };
2297
+ var sanitizeUrl = (url) => {
2298
+ try {
2299
+ const parsed = new URL(url);
2300
+ if (!parsed.searchParams.has("session"))
2301
+ return url;
2302
+ parsed.searchParams.set("session", "<redacted>");
2303
+ return parsed.toString();
2304
+ } catch {
2305
+ return url.replace(/([?&]session=)[^&]*/i, "$1<redacted>");
2306
+ }
2307
+ };
2296
2308
  function parseFormatFromUrl(url) {
2297
2309
  try {
2298
2310
  const f = new URL(url).searchParams.get("f");
@@ -2740,7 +2752,6 @@ var RpcClientPeer = class extends RpcPeer {
2740
2752
  }
2741
2753
  async _runImpl() {
2742
2754
  if (this._disposed) return;
2743
- const connUrl = this.connectionUrlResolver(this);
2744
2755
  infoLog?.log(`'${this.ref}': Started (Client)`);
2745
2756
  try {
2746
2757
  while (!this._disposed) {
@@ -2761,7 +2772,8 @@ var RpcClientPeer = class extends RpcPeer {
2761
2772
  let lastCloseCode = 0;
2762
2773
  let lastCloseReason = "";
2763
2774
  try {
2764
- infoLog?.log(`'${this.ref}': Connecting to ${connUrl}`);
2775
+ const connUrl = await this.connectionUrlResolver(this);
2776
+ infoLog?.log(`'${this.ref}': Connecting to ${sanitizeUrl(connUrl)}`);
2765
2777
  const ws = this.webSocketFactory?.(connUrl) ?? new WebSocket(connUrl);
2766
2778
  const conn = new RpcWebSocketConnection(
2767
2779
  ws,