@actuallab/rpc 12.3.79 → 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 +27 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
RpcClientPeer: () => RpcClientPeer,
|
|
42
42
|
RpcClientPeerReconnectDelayer: () => RpcClientPeerReconnectDelayer,
|
|
43
43
|
RpcConnectionState: () => RpcConnectionState,
|
|
44
|
+
RpcError: () => RpcError,
|
|
44
45
|
RpcHub: () => RpcHub,
|
|
45
46
|
RpcInboundCall: () => RpcInboundCall,
|
|
46
47
|
RpcInboundCallTracker: () => RpcInboundCallTracker,
|
|
@@ -862,6 +863,17 @@ var RpcInboundCallTracker = class {
|
|
|
862
863
|
}
|
|
863
864
|
};
|
|
864
865
|
|
|
866
|
+
// src/rpc-error.ts
|
|
867
|
+
var RpcError = class extends Error {
|
|
868
|
+
typeName;
|
|
869
|
+
constructor(message, typeName) {
|
|
870
|
+
super(message);
|
|
871
|
+
this.name = "RpcError";
|
|
872
|
+
if (typeName !== void 0)
|
|
873
|
+
this.typeName = typeName;
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
|
|
865
877
|
// src/increasing-seq-compressor.ts
|
|
866
878
|
var IncreasingSeqCompressor = {
|
|
867
879
|
/**
|
|
@@ -1471,6 +1483,7 @@ var RpcStream = class _RpcStream {
|
|
|
1471
1483
|
_started = false;
|
|
1472
1484
|
_iterating = false;
|
|
1473
1485
|
_ackSentUpTo = 0;
|
|
1486
|
+
_nextConsumedIndex = 0;
|
|
1474
1487
|
constructor(sourceOrRef, optionsOrPeer) {
|
|
1475
1488
|
if (_isStreamSource(sourceOrRef)) {
|
|
1476
1489
|
const options = optionsOrPeer ?? {};
|
|
@@ -1562,12 +1575,11 @@ var RpcStream = class _RpcStream {
|
|
|
1562
1575
|
return;
|
|
1563
1576
|
}
|
|
1564
1577
|
if (index < this._nextExpectedIndex) {
|
|
1565
|
-
this._maybeSendAck(index + 1);
|
|
1578
|
+
this._maybeSendAck(Math.min(index + 1, this._nextConsumedIndex));
|
|
1566
1579
|
return;
|
|
1567
1580
|
}
|
|
1568
1581
|
this._buffer.push(item);
|
|
1569
1582
|
this._nextExpectedIndex = index + 1;
|
|
1570
|
-
this._maybeSendAck(this._nextExpectedIndex);
|
|
1571
1583
|
this._notifyConsumer();
|
|
1572
1584
|
}
|
|
1573
1585
|
/** Called by system call handler when a batch arrives ($sys.B). */
|
|
@@ -1587,12 +1599,11 @@ var RpcStream = class _RpcStream {
|
|
|
1587
1599
|
return;
|
|
1588
1600
|
}
|
|
1589
1601
|
if (index < this._nextExpectedIndex) {
|
|
1590
|
-
this._maybeSendAck(index + items.length);
|
|
1602
|
+
this._maybeSendAck(Math.min(index + items.length, this._nextConsumedIndex));
|
|
1591
1603
|
return;
|
|
1592
1604
|
}
|
|
1593
1605
|
for (const item of items) this._buffer.push(item);
|
|
1594
1606
|
this._nextExpectedIndex = index + items.length;
|
|
1595
|
-
this._maybeSendAck(this._nextExpectedIndex);
|
|
1596
1607
|
this._notifyConsumer();
|
|
1597
1608
|
}
|
|
1598
1609
|
/** Called by system call handler when the stream ends ($sys.End). */
|
|
@@ -1636,9 +1647,11 @@ var RpcStream = class _RpcStream {
|
|
|
1636
1647
|
this._started = true;
|
|
1637
1648
|
this._sendAck(0, true);
|
|
1638
1649
|
}
|
|
1650
|
+
this._maybeSendAck(this._nextConsumedIndex);
|
|
1639
1651
|
for (; ; ) {
|
|
1640
1652
|
if (!this._buffer.isEmpty()) {
|
|
1641
1653
|
const value = this._buffer.shift();
|
|
1654
|
+
this._nextConsumedIndex++;
|
|
1642
1655
|
return { value, done: false };
|
|
1643
1656
|
}
|
|
1644
1657
|
if (this._completed) {
|
|
@@ -1788,12 +1801,17 @@ var RpcSystemCallHandler = class {
|
|
|
1788
1801
|
const errorInfo = args[0];
|
|
1789
1802
|
const msg = errorInfo?.Message ?? errorInfo?.message ?? "RPC error";
|
|
1790
1803
|
const errorType = errorInfo?.TypeRef ?? errorInfo?.typeRef;
|
|
1791
|
-
|
|
1804
|
+
let typeName;
|
|
1805
|
+
if (typeof errorType === "string") {
|
|
1806
|
+
const commaIdx = errorType.indexOf(",");
|
|
1807
|
+
typeName = commaIdx >= 0 ? errorType.slice(0, commaIdx) : errorType;
|
|
1808
|
+
} else if (errorType !== null && typeof errorType === "object") {
|
|
1792
1809
|
const t = errorType;
|
|
1793
|
-
|
|
1794
|
-
warnLog5?.log("Got RpcRerouteException from remote peer:", msg);
|
|
1810
|
+
typeName = t.TypeName ?? t.typeName;
|
|
1795
1811
|
}
|
|
1796
|
-
|
|
1812
|
+
if (typeName === "ActualLab.Rpc.RpcRerouteException")
|
|
1813
|
+
warnLog5?.log("Got RpcRerouteException from remote peer:", msg);
|
|
1814
|
+
call.result.reject(new RpcError(msg, typeName));
|
|
1797
1815
|
}
|
|
1798
1816
|
break;
|
|
1799
1817
|
}
|
|
@@ -4098,6 +4116,7 @@ var RpcPeerStateMonitor = class {
|
|
|
4098
4116
|
RpcClientPeer,
|
|
4099
4117
|
RpcClientPeerReconnectDelayer,
|
|
4100
4118
|
RpcConnectionState,
|
|
4119
|
+
RpcError,
|
|
4101
4120
|
RpcHub,
|
|
4102
4121
|
RpcInboundCall,
|
|
4103
4122
|
RpcInboundCallTracker,
|