@actuallab/rpc 12.3.81 → 12.3.83
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 +5 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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) {
|