@actuallab/rpc 14.3.34 → 14.4.3
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 +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -993,7 +993,8 @@ var RpcCallTimeouts = class _RpcCallTimeouts {
|
|
|
993
993
|
static None = new _RpcCallTimeouts(Infinity, Infinity);
|
|
994
994
|
/** Command default: 1.5 s connect / 10 s run (.NET `RpcCallTimeouts.Default.Command`). */
|
|
995
995
|
static Command = new _RpcCallTimeouts(1500, 1e4);
|
|
996
|
-
/** Max time a call may wait for
|
|
996
|
+
/** Max time a call may wait for a connection - before it is sent, and again for the
|
|
997
|
+
* duration of any outage it is still pending through. */
|
|
997
998
|
connectTimeoutMs;
|
|
998
999
|
/** Max time a sent call may stay unanswered before it is failed. */
|
|
999
1000
|
runTimeoutMs;
|
|
@@ -2787,6 +2788,8 @@ var RpcPeer = class {
|
|
|
2787
2788
|
/** Wall-clock time of the last inbound `$sys.KeepAlive`, or 0 if none yet
|
|
2788
2789
|
* for the current connection. Useful for diagnostics. */
|
|
2789
2790
|
_lastKeepAliveAt = 0;
|
|
2791
|
+
/** When the current outage began; 0 until the peer has been connected at least once. */
|
|
2792
|
+
_disconnectedAt = 0;
|
|
2790
2793
|
/** Outbound keep-alive send period. Initialized from `hub.limits` at
|
|
2791
2794
|
* construction; set directly to override on a single peer. */
|
|
2792
2795
|
keepAlivePeriodMs;
|
|
@@ -2807,9 +2810,10 @@ var RpcPeer = class {
|
|
|
2807
2810
|
}
|
|
2808
2811
|
/** Fail outbound calls whose per-call {@link RpcCallTimeouts} elapsed —
|
|
2809
2812
|
* the connect timeout while a call still awaits the wire, the run timeout
|
|
2810
|
-
* once it has been sent
|
|
2811
|
-
*
|
|
2812
|
-
*
|
|
2813
|
+
* once it has been sent, and the connect timeout again for any pending call while the
|
|
2814
|
+
* peer is away. Mirrors .NET `RpcOutboundCallTracker.HandleDisconnect` (ConnectTimeout,
|
|
2815
|
+
* per outage) plus `Maintain` (RunTimeout, per connection). Calls without timeouts
|
|
2816
|
+
* (queries) never time out here. */
|
|
2813
2817
|
_maintainOutboundCalls() {
|
|
2814
2818
|
const now = Date.now();
|
|
2815
2819
|
const canRunTimeout = this._isConnected && (this._lastKeepAliveAt === 0 || now - this._lastKeepAliveAt <= this.keepAliveTimeoutMs);
|
|
@@ -2818,7 +2822,11 @@ var RpcPeer = class {
|
|
|
2818
2822
|
if (timeouts === void 0 || call.result.isCompleted)
|
|
2819
2823
|
continue;
|
|
2820
2824
|
let timedOut;
|
|
2821
|
-
if (
|
|
2825
|
+
if (!this._isConnected) {
|
|
2826
|
+
const since = Math.max(this._disconnectedAt, call.startedAt);
|
|
2827
|
+
if (now - since >= timeouts.connectTimeoutMs)
|
|
2828
|
+
timedOut = `connect timeout (${timeouts.connectTimeoutMs}ms)`;
|
|
2829
|
+
} else if (call.sentAt === 0) {
|
|
2822
2830
|
if (now - call.startedAt >= timeouts.connectTimeoutMs)
|
|
2823
2831
|
timedOut = `connect timeout (${timeouts.connectTimeoutMs}ms)`;
|
|
2824
2832
|
} else if (canRunTimeout && now - call.sentAt >= timeouts.runTimeoutMs)
|
|
@@ -2861,10 +2869,13 @@ var RpcPeer = class {
|
|
|
2861
2869
|
this._connectionState = value;
|
|
2862
2870
|
if (value === 3 /* Connected */) {
|
|
2863
2871
|
this._isConnected = true;
|
|
2872
|
+
this._disconnectedAt = 0;
|
|
2864
2873
|
this._armKeepAliveWatchdog();
|
|
2865
2874
|
} else if (value === 0 /* Disconnected */) {
|
|
2866
|
-
if (previousState === 3 /* Connected */)
|
|
2875
|
+
if (previousState === 3 /* Connected */) {
|
|
2867
2876
|
this._isConnected = false;
|
|
2877
|
+
this._disconnectedAt = Date.now();
|
|
2878
|
+
}
|
|
2868
2879
|
this._disarmKeepAliveWatchdog();
|
|
2869
2880
|
}
|
|
2870
2881
|
this.connectionStateChanged.trigger(value);
|
|
@@ -2889,6 +2900,8 @@ var RpcPeer = class {
|
|
|
2889
2900
|
conn.closed.add((ev) => {
|
|
2890
2901
|
if (this._connection !== conn) return;
|
|
2891
2902
|
this._connection = void 0;
|
|
2903
|
+
if (this._isConnected)
|
|
2904
|
+
this._disconnectedAt = Date.now();
|
|
2892
2905
|
this._isConnected = false;
|
|
2893
2906
|
if (ev.reason)
|
|
2894
2907
|
infoLog?.log(`'${this.ref}': Disconnected: ${ev.reason} (code=${ev.code})`);
|