@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.js
CHANGED
|
@@ -2365,6 +2365,7 @@ function toRpcStream(value, peer) {
|
|
|
2365
2365
|
}
|
|
2366
2366
|
|
|
2367
2367
|
// src/rpc-remote-object-tracker.ts
|
|
2368
|
+
var { warnLog: warnLog7 } = getLogs("RpcRemoteObjectTracker");
|
|
2368
2369
|
var RpcRemoteObjectTracker = class {
|
|
2369
2370
|
_objects = /* @__PURE__ */ new Map();
|
|
2370
2371
|
register(obj) {
|
|
@@ -2395,8 +2396,17 @@ var RpcRemoteObjectTracker = class {
|
|
|
2395
2396
|
}
|
|
2396
2397
|
reconnectAll() {
|
|
2397
2398
|
for (const obj of this._objects.values()) {
|
|
2398
|
-
|
|
2399
|
-
|
|
2399
|
+
try {
|
|
2400
|
+
if (obj.allowReconnect) obj.reconnect();
|
|
2401
|
+
else obj.disconnect();
|
|
2402
|
+
} catch (e) {
|
|
2403
|
+
warnLog7?.log(`Failed to reconnect ${obj.id.localId}, disconnecting it`, e);
|
|
2404
|
+
try {
|
|
2405
|
+
obj.disconnect();
|
|
2406
|
+
} catch (e2) {
|
|
2407
|
+
warnLog7?.log(`Failed to disconnect ${obj.id.localId}`, e2);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2400
2410
|
}
|
|
2401
2411
|
}
|
|
2402
2412
|
};
|
|
@@ -2621,7 +2631,7 @@ function yieldToEventLoop() {
|
|
|
2621
2631
|
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
2622
2632
|
}
|
|
2623
2633
|
var RPC_CLOSE_CODE_UNSUPPORTED_FORMAT = 4001;
|
|
2624
|
-
var { debugLog: debugLog2, infoLog, warnLog:
|
|
2634
|
+
var { debugLog: debugLog2, infoLog, warnLog: warnLog8, errorLog: errorLog2 } = getLogs("RpcPeer");
|
|
2625
2635
|
var defaultConnectionUrlResolver = async (peer) => {
|
|
2626
2636
|
const formatKey = peer.serializationFormat.key;
|
|
2627
2637
|
const proof = await peer.computeReconnectProof();
|
|
@@ -3093,9 +3103,13 @@ var RpcPeer = class {
|
|
|
3093
3103
|
this._keepAliveTimer ??= setInterval(() => {
|
|
3094
3104
|
const conn = this.wireConnection;
|
|
3095
3105
|
if (conn !== void 0) {
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3106
|
+
try {
|
|
3107
|
+
this.hub.systemCallSender.keepAlive(conn, this.serializationFormat, [
|
|
3108
|
+
...this.remoteObjects.keys()
|
|
3109
|
+
]);
|
|
3110
|
+
} catch (e) {
|
|
3111
|
+
warnLog8?.log(`'${this.ref}': Failed to send keep-alive`, e);
|
|
3112
|
+
}
|
|
3099
3113
|
}
|
|
3100
3114
|
}, this.keepAlivePeriodMs);
|
|
3101
3115
|
if (this._keepAliveWatchdog !== void 0)
|
|
@@ -3103,7 +3117,7 @@ var RpcPeer = class {
|
|
|
3103
3117
|
this._keepAliveWatchdog = setTimeout(() => {
|
|
3104
3118
|
this._keepAliveWatchdog = void 0;
|
|
3105
3119
|
if (this._connection === void 0) return;
|
|
3106
|
-
|
|
3120
|
+
warnLog8?.log(
|
|
3107
3121
|
`'${this.ref}': no keep-alive for ${this.keepAliveTimeoutMs}ms \u2014 force-closing connection`
|
|
3108
3122
|
);
|
|
3109
3123
|
this._connection.close();
|
|
@@ -3304,7 +3318,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3304
3318
|
this._setConnectionState(1 /* Connecting */);
|
|
3305
3319
|
const retryDelay = this.hub.reconnectDelayer.getDelay(this._tryIndex, this._stopController.signal);
|
|
3306
3320
|
if (retryDelay.isLimitExceeded) {
|
|
3307
|
-
|
|
3321
|
+
warnLog8?.log(`'${this.ref}': Reconnect limit exceeded - shutting down`);
|
|
3308
3322
|
this._disposed = true;
|
|
3309
3323
|
break;
|
|
3310
3324
|
}
|
|
@@ -3353,7 +3367,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3353
3367
|
);
|
|
3354
3368
|
} catch (e) {
|
|
3355
3369
|
if (e instanceof TimeoutError) {
|
|
3356
|
-
|
|
3370
|
+
warnLog8?.log(`'${this.ref}': Connect timed out after ${connectTimeoutMs}ms`);
|
|
3357
3371
|
conn.close();
|
|
3358
3372
|
}
|
|
3359
3373
|
throw e;
|
|
@@ -3368,7 +3382,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3368
3382
|
this.nextOwnHandshakeIndex()
|
|
3369
3383
|
);
|
|
3370
3384
|
} catch (e) {
|
|
3371
|
-
|
|
3385
|
+
warnLog8?.log(`'${this.ref}': Failed to send handshake`, e);
|
|
3372
3386
|
throw e;
|
|
3373
3387
|
}
|
|
3374
3388
|
const handshakeTimeoutMs = this.handshakeTimeoutMs;
|
|
@@ -3381,7 +3395,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3381
3395
|
);
|
|
3382
3396
|
} catch (e) {
|
|
3383
3397
|
if (e instanceof TimeoutError) {
|
|
3384
|
-
|
|
3398
|
+
warnLog8?.log(`'${this.ref}': Handshake timed out after ${handshakeTimeoutMs}ms`);
|
|
3385
3399
|
conn.close();
|
|
3386
3400
|
}
|
|
3387
3401
|
throw e;
|
|
@@ -3411,7 +3425,7 @@ var RpcClientPeer = class extends RpcPeer {
|
|
|
3411
3425
|
this._setConnectionState(0 /* Disconnected */);
|
|
3412
3426
|
if (this._disposed) break;
|
|
3413
3427
|
if (lastCloseCode === RPC_CLOSE_CODE_UNSUPPORTED_FORMAT) {
|
|
3414
|
-
|
|
3428
|
+
warnLog8?.log(`'${this.ref}': Unsupported serialization format - shutting down`);
|
|
3415
3429
|
this.unsupportedFormat.trigger({ reason: lastCloseReason });
|
|
3416
3430
|
this._disposed = true;
|
|
3417
3431
|
break;
|
|
@@ -3666,7 +3680,7 @@ function warnReconnectProofUnavailable(ref, reason) {
|
|
|
3666
3680
|
if (isReconnectProofUnavailableWarned)
|
|
3667
3681
|
return;
|
|
3668
3682
|
isReconnectProofUnavailableWarned = true;
|
|
3669
|
-
|
|
3683
|
+
warnLog8?.log(
|
|
3670
3684
|
`'${ref}': ${reason} - connecting without a reconnect proof. This fails if the server requires one (RequireReconnectProof).`
|
|
3671
3685
|
);
|
|
3672
3686
|
}
|
|
@@ -3747,7 +3761,7 @@ var RpcClientPeerReconnectDelayer = class extends RetryDelayer {
|
|
|
3747
3761
|
};
|
|
3748
3762
|
|
|
3749
3763
|
// src/rpc-service-host.ts
|
|
3750
|
-
var { warnLog:
|
|
3764
|
+
var { warnLog: warnLog9 } = getLogs("RpcServiceHost");
|
|
3751
3765
|
var RpcServiceHost = class {
|
|
3752
3766
|
_methods = /* @__PURE__ */ new Map();
|
|
3753
3767
|
register(def, impl, receiver = impl) {
|
|
@@ -3764,7 +3778,7 @@ var RpcServiceHost = class {
|
|
|
3764
3778
|
async dispatch(wireMethod, args, context) {
|
|
3765
3779
|
const entry = this._methods.get(wireMethod);
|
|
3766
3780
|
if (entry === void 0) {
|
|
3767
|
-
|
|
3781
|
+
warnLog9?.log(`Method not found: ${wireMethod}`);
|
|
3768
3782
|
throw new Error(`Method not found: ${wireMethod}`);
|
|
3769
3783
|
}
|
|
3770
3784
|
if (context !== void 0 && entry.def.callTypeId !== 0) {
|
|
@@ -4297,7 +4311,7 @@ function computeMethodHash(methodName) {
|
|
|
4297
4311
|
}
|
|
4298
4312
|
|
|
4299
4313
|
// src/rpc-method-registry.ts
|
|
4300
|
-
var { warnLog:
|
|
4314
|
+
var { warnLog: warnLog10 } = getLogs("RpcMethodRegistry");
|
|
4301
4315
|
var RpcMethodRegistry = class {
|
|
4302
4316
|
_nameToHash = /* @__PURE__ */ new Map();
|
|
4303
4317
|
_hashToName = /* @__PURE__ */ new Map();
|
|
@@ -4307,7 +4321,7 @@ var RpcMethodRegistry = class {
|
|
|
4307
4321
|
const hash = computeMethodHash(methodName);
|
|
4308
4322
|
const existing = this._hashToName.get(hash);
|
|
4309
4323
|
if (existing !== void 0 && existing !== methodName) {
|
|
4310
|
-
|
|
4324
|
+
warnLog10?.log(`hash collision: "${methodName}" and "${existing}" both hash to ${hash}`);
|
|
4311
4325
|
return;
|
|
4312
4326
|
}
|
|
4313
4327
|
this._nameToHash.set(methodName, hash);
|
|
@@ -4340,7 +4354,7 @@ var RpcMethodRegistry = class {
|
|
|
4340
4354
|
};
|
|
4341
4355
|
|
|
4342
4356
|
// src/rpc-hub.ts
|
|
4343
|
-
var { warnLog:
|
|
4357
|
+
var { warnLog: warnLog11 } = getLogs("RpcHub");
|
|
4344
4358
|
var RpcHub = class {
|
|
4345
4359
|
hubId;
|
|
4346
4360
|
peers = /* @__PURE__ */ new Map();
|
|
@@ -4405,7 +4419,7 @@ var RpcHub = class {
|
|
|
4405
4419
|
if (peer !== void 0) {
|
|
4406
4420
|
peer.close();
|
|
4407
4421
|
this.peers.delete(ref);
|
|
4408
|
-
|
|
4422
|
+
warnLog11?.log(`'${ref}': peer is removed from RpcHub`);
|
|
4409
4423
|
}
|
|
4410
4424
|
}
|
|
4411
4425
|
/** Get or create a peer by ref. If the peer does not exist:
|