@actuallab/rpc 14.4.11 → 15.0.17
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 +33 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -19
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2479,6 +2479,7 @@ function toRpcStream(value, peer) {
|
|
|
2479
2479
|
}
|
|
2480
2480
|
|
|
2481
2481
|
// src/rpc-remote-object-tracker.ts
|
|
2482
|
+
var { warnLog: warnLog7 } = getLogs("RpcRemoteObjectTracker");
|
|
2482
2483
|
var RpcRemoteObjectTracker = class {
|
|
2483
2484
|
_objects = /* @__PURE__ */ new Map();
|
|
2484
2485
|
register(obj) {
|
|
@@ -2509,8 +2510,17 @@ var RpcRemoteObjectTracker = class {
|
|
|
2509
2510
|
}
|
|
2510
2511
|
reconnectAll() {
|
|
2511
2512
|
for (const obj of this._objects.values()) {
|
|
2512
|
-
|
|
2513
|
-
|
|
2513
|
+
try {
|
|
2514
|
+
if (obj.allowReconnect) obj.reconnect();
|
|
2515
|
+
else obj.disconnect();
|
|
2516
|
+
} catch (e) {
|
|
2517
|
+
warnLog7?.log(`Failed to reconnect ${obj.id.localId}, disconnecting it`, e);
|
|
2518
|
+
try {
|
|
2519
|
+
obj.disconnect();
|
|
2520
|
+
} catch (e2) {
|
|
2521
|
+
warnLog7?.log(`Failed to disconnect ${obj.id.localId}`, e2);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2514
2524
|
}
|
|
2515
2525
|
}
|
|
2516
2526
|
};
|
|
@@ -2735,7 +2745,7 @@ function yieldToEventLoop() {
|
|
|
2735
2745
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
2736
2746
|
}
|
|
2737
2747
|
var RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
|
|
2738
|
-
var { debugLog: debugLog2, infoLog, warnLog:
|
|
2748
|
+
var { debugLog: debugLog2, infoLog, warnLog: warnLog8, errorLog: errorLog2 } = getLogs("RpcPeer");
|
|
2739
2749
|
var defaultConnectionUrlResolver = async (peer) => {
|
|
2740
2750
|
const formatKey = peer.serializationFormat.key;
|
|
2741
2751
|
const proof = await peer.computeReconnectProof();
|
|
@@ -3207,9 +3217,13 @@ var RpcPeer = class {
|
|
|
3207
3217
|
this._keepAliveTimer ??= setInterval(() => {
|
|
3208
3218
|
const conn = this.wireConnection;
|
|
3209
3219
|
if (conn !== void 0) {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3220
|
+
try {
|
|
3221
|
+
this.hub.systemCallSender.keepAlive(conn, this.serializationFormat, [
|
|
3222
|
+
...this.remoteObjects.keys()
|
|
3223
|
+
]);
|
|
3224
|
+
} catch (e) {
|
|
3225
|
+
warnLog8?.log(`'${this.ref}': Failed to send keep-alive`, e);
|
|
3226
|
+
}
|
|
3213
3227
|
}
|
|
3214
3228
|
}, this.keepAlivePeriodMs);
|
|
3215
3229
|
if (this._keepAliveWatchdog !== void 0)
|
|
@@ -3217,7 +3231,7 @@ var RpcPeer = class {
|
|
|
3217
3231
|
this._keepAliveWatchdog = setTimeout(() => {
|
|
3218
3232
|
this._keepAliveWatchdog = void 0;
|
|
3219
3233
|
if (this._connection === void 0) return;
|
|
3220
|
-
|
|
3234
|
+
warnLog8?.log(
|
|
3221
3235
|
`'${this.ref}': no keep-alive for ${this.keepAliveTimeoutMs}ms \u2014 force-closing connection`
|
|
3222
3236
|
);
|
|
3223
3237
|
this._connection.close();
|
|
@@ -3418,7 +3432,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3418
3432
|
this._setConnectionState(1 /* Connecting */);
|
|
3419
3433
|
const retryDelay = this.hub.reconnectDelayer.getDelay(this._tryIndex, this._stopController.signal);
|
|
3420
3434
|
if (retryDelay.isLimitExceeded) {
|
|
3421
|
-
|
|
3435
|
+
warnLog8?.log(`'${this.ref}': Reconnect limit exceeded - shutting down`);
|
|
3422
3436
|
this._disposed = true;
|
|
3423
3437
|
break;
|
|
3424
3438
|
}
|
|
@@ -3467,7 +3481,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3467
3481
|
);
|
|
3468
3482
|
} catch (e) {
|
|
3469
3483
|
if (e instanceof import_core7.TimeoutError) {
|
|
3470
|
-
|
|
3484
|
+
warnLog8?.log(`'${this.ref}': Connect timed out after ${connectTimeoutMs}ms`);
|
|
3471
3485
|
conn.close();
|
|
3472
3486
|
}
|
|
3473
3487
|
throw e;
|
|
@@ -3482,7 +3496,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3482
3496
|
this.nextOwnHandshakeIndex()
|
|
3483
3497
|
);
|
|
3484
3498
|
} catch (e) {
|
|
3485
|
-
|
|
3499
|
+
warnLog8?.log(`'${this.ref}': Failed to send handshake`, e);
|
|
3486
3500
|
throw e;
|
|
3487
3501
|
}
|
|
3488
3502
|
const handshakeTimeoutMs = this.handshakeTimeoutMs;
|
|
@@ -3495,7 +3509,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3495
3509
|
);
|
|
3496
3510
|
} catch (e) {
|
|
3497
3511
|
if (e instanceof import_core7.TimeoutError) {
|
|
3498
|
-
|
|
3512
|
+
warnLog8?.log(`'${this.ref}': Handshake timed out after ${handshakeTimeoutMs}ms`);
|
|
3499
3513
|
conn.close();
|
|
3500
3514
|
}
|
|
3501
3515
|
throw e;
|
|
@@ -3525,7 +3539,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3525
3539
|
this._setConnectionState(0 /* Disconnected */);
|
|
3526
3540
|
if (this._disposed) break;
|
|
3527
3541
|
if (lastCloseCode === RPC_CLOSE_CODE_UNSUPPORTED_FORMAT) {
|
|
3528
|
-
|
|
3542
|
+
warnLog8?.log(`'${this.ref}': Unsupported serialization format - shutting down`);
|
|
3529
3543
|
this.unsupportedFormat.trigger({ reason: lastCloseReason });
|
|
3530
3544
|
this._disposed = true;
|
|
3531
3545
|
break;
|
|
@@ -3780,7 +3794,7 @@ function warnReconnectProofUnavailable(ref, reason) {
|
|
|
3780
3794
|
if (isReconnectProofUnavailableWarned)
|
|
3781
3795
|
return;
|
|
3782
3796
|
isReconnectProofUnavailableWarned = true;
|
|
3783
|
-
|
|
3797
|
+
warnLog8?.log(
|
|
3784
3798
|
`'${ref}': ${reason} - connecting without a reconnect proof. This fails if the server requires one (RequireReconnectProof).`
|
|
3785
3799
|
);
|
|
3786
3800
|
}
|
|
@@ -3861,7 +3875,7 @@ var RpcClientPeerReconnectDelayer = class extends import_core8.RetryDelayer {
|
|
|
3861
3875
|
};
|
|
3862
3876
|
|
|
3863
3877
|
// src/rpc-service-host.ts
|
|
3864
|
-
var { warnLog:
|
|
3878
|
+
var { warnLog: warnLog9 } = getLogs("RpcServiceHost");
|
|
3865
3879
|
var RpcServiceHost = class {
|
|
3866
3880
|
_methods = /* @__PURE__ */ new Map();
|
|
3867
3881
|
register(def, impl, receiver = impl) {
|
|
@@ -3878,7 +3892,7 @@ var RpcServiceHost = class {
|
|
|
3878
3892
|
async dispatch(wireMethod, args, context) {
|
|
3879
3893
|
const entry = this._methods.get(wireMethod);
|
|
3880
3894
|
if (entry === void 0) {
|
|
3881
|
-
|
|
3895
|
+
warnLog9?.log(`Method not found: ${wireMethod}`);
|
|
3882
3896
|
throw new Error(`Method not found: ${wireMethod}`);
|
|
3883
3897
|
}
|
|
3884
3898
|
if (context !== void 0 && entry.def.callTypeId !== 0) {
|
|
@@ -4411,7 +4425,7 @@ function computeMethodHash(methodName) {
|
|
|
4411
4425
|
}
|
|
4412
4426
|
|
|
4413
4427
|
// src/rpc-method-registry.ts
|
|
4414
|
-
var { warnLog:
|
|
4428
|
+
var { warnLog: warnLog10 } = getLogs("RpcMethodRegistry");
|
|
4415
4429
|
var RpcMethodRegistry = class {
|
|
4416
4430
|
_nameToHash = /* @__PURE__ */ new Map();
|
|
4417
4431
|
_hashToName = /* @__PURE__ */ new Map();
|
|
@@ -4421,7 +4435,7 @@ var RpcMethodRegistry = class {
|
|
|
4421
4435
|
const hash = computeMethodHash(methodName);
|
|
4422
4436
|
const existing = this._hashToName.get(hash);
|
|
4423
4437
|
if (existing !== void 0 && existing !== methodName) {
|
|
4424
|
-
|
|
4438
|
+
warnLog10?.log(`hash collision: "${methodName}" and "${existing}" both hash to ${hash}`);
|
|
4425
4439
|
return;
|
|
4426
4440
|
}
|
|
4427
4441
|
this._nameToHash.set(methodName, hash);
|
|
@@ -4454,7 +4468,7 @@ var RpcMethodRegistry = class {
|
|
|
4454
4468
|
};
|
|
4455
4469
|
|
|
4456
4470
|
// src/rpc-hub.ts
|
|
4457
|
-
var { warnLog:
|
|
4471
|
+
var { warnLog: warnLog11 } = getLogs("RpcHub");
|
|
4458
4472
|
var RpcHub = class {
|
|
4459
4473
|
hubId;
|
|
4460
4474
|
peers = /* @__PURE__ */ new Map();
|
|
@@ -4519,7 +4533,7 @@ var RpcHub = class {
|
|
|
4519
4533
|
if (peer !== void 0) {
|
|
4520
4534
|
peer.close();
|
|
4521
4535
|
this.peers.delete(ref);
|
|
4522
|
-
|
|
4536
|
+
warnLog11?.log(`'${ref}': peer is removed from RpcHub`);
|
|
4523
4537
|
}
|
|
4524
4538
|
}
|
|
4525
4539
|
/** Get or create a peer by ref. If the peer does not exist:
|