@actuallab/rpc 12.3.76 → 12.3.81
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 +24 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -523,6 +523,12 @@ declare const RpcCallStage: {
|
|
|
523
523
|
};
|
|
524
524
|
type RpcCallStage = number;
|
|
525
525
|
|
|
526
|
+
/** Error thrown for a failed remote RPC call — carries the remote exception's type name when available. */
|
|
527
|
+
declare class RpcError extends Error {
|
|
528
|
+
readonly typeName?: string;
|
|
529
|
+
constructor(message: string, typeName?: string);
|
|
530
|
+
}
|
|
531
|
+
|
|
526
532
|
/**
|
|
527
533
|
* Compresses and decompresses monotonically increasing sequences of
|
|
528
534
|
* integers using variable-length LEB128 encoding of successive deltas.
|
|
@@ -1288,4 +1294,4 @@ declare function xxh3_64str(input: string, seed?: bigint): bigint;
|
|
|
1288
1294
|
*/
|
|
1289
1295
|
declare function computeMethodHash(methodName: string): number;
|
|
1290
1296
|
|
|
1291
|
-
export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, HANDSHAKE_TIMEOUT_MS, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonSerializationFormat, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactSerializationFormat, RpcMessagePackSerializationFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, type RpcPeerFactory, RpcPeerRefBuilder, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcSerializationFormat, RpcSerializationFormatResolver, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, wireMethodName, xxh3_64, xxh3_64str };
|
|
1297
|
+
export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, HANDSHAKE_TIMEOUT_MS, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcError, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonSerializationFormat, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactSerializationFormat, RpcMessagePackSerializationFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, type RpcPeerFactory, RpcPeerRefBuilder, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcSerializationFormat, RpcSerializationFormatResolver, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, wireMethodName, xxh3_64, xxh3_64str };
|
package/dist/index.d.ts
CHANGED
|
@@ -523,6 +523,12 @@ declare const RpcCallStage: {
|
|
|
523
523
|
};
|
|
524
524
|
type RpcCallStage = number;
|
|
525
525
|
|
|
526
|
+
/** Error thrown for a failed remote RPC call — carries the remote exception's type name when available. */
|
|
527
|
+
declare class RpcError extends Error {
|
|
528
|
+
readonly typeName?: string;
|
|
529
|
+
constructor(message: string, typeName?: string);
|
|
530
|
+
}
|
|
531
|
+
|
|
526
532
|
/**
|
|
527
533
|
* Compresses and decompresses monotonically increasing sequences of
|
|
528
534
|
* integers using variable-length LEB128 encoding of successive deltas.
|
|
@@ -1288,4 +1294,4 @@ declare function xxh3_64str(input: string, seed?: bigint): bigint;
|
|
|
1288
1294
|
*/
|
|
1289
1295
|
declare function computeMethodHash(methodName: string): number;
|
|
1290
1296
|
|
|
1291
|
-
export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, HANDSHAKE_TIMEOUT_MS, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonSerializationFormat, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactSerializationFormat, RpcMessagePackSerializationFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, type RpcPeerFactory, RpcPeerRefBuilder, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcSerializationFormat, RpcSerializationFormatResolver, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, wireMethodName, xxh3_64, xxh3_64str };
|
|
1297
|
+
export { ARG_DELIMITER, ENVELOPE_DELIMITER, FRAME_DELIMITER, HANDSHAKE_TIMEOUT_MS, type IRpcObject, IncreasingSeqCompressor, type MethodMeta, RPC_CLOSE_CODE_UNSUPPORTED_FORMAT, type RemoteHandshake, type RpcCallOptions, RpcCallStage, RpcCallTypeId, RpcClientPeer, RpcClientPeerReconnectDelayer, type RpcConnection, RpcConnectionState, type RpcConnectionUrlResolver, type RpcDeserializedMessage, type RpcDispatchContext, RpcError, RpcHub, RpcInboundCall, RpcInboundCallTracker, RpcJsonSerializationFormat, type RpcLogScope, type RpcMessage, RpcMessageChannelConnection, RpcMessagePackCompactSerializationFormat, RpcMessagePackSerializationFormat, type RpcMethodDef, type RpcMethodDefInput, RpcMethodRegistry, type RpcObjectId, RpcObjectKind, RpcOutboundCall, RpcOutboundCallTracker, RpcPeer, type RpcPeerFactory, RpcPeerRefBuilder, type RpcPeerState, RpcPeerStateKind, RpcPeerStateMonitor, type RpcReceivedMessage, RpcRemoteExecutionMode, RpcRemoteObjectTracker, RpcSerializationFormat, RpcSerializationFormatResolver, RpcServerPeer, type RpcServiceDef, RpcServiceHost, type RpcServiceImpl, RpcSharedObjectTracker, RpcStream, type RpcStreamOptions, type RpcStreamRef, RpcStreamSender, type RpcStreamSource, RpcSystemCallHandler, RpcSystemCallSender, RpcSystemCalls, RpcType, RpcWebSocketConnection, type RpcWireData, type ServiceMeta, type WebSocketLike, type WebSocketServer, WebSocketState, computeMethodHash, createBinaryEncoder, createMessageChannelPair, createRpcClient, defaultBinaryDecoder, defaultBinaryEncoder, defaultConnectionUrlResolver, defineRpcService, deserializeBinaryMessage, deserializeCompactBinaryMessage, deserializeMessage, getLogs, getMethodsMeta, getServiceMeta, getStateDescription, isConnected, likelyConnected, parseStreamRef, resolveStreamRefs, rpcMethod, rpcService, serializeBinaryFrame, serializeBinaryMessage, serializeCompactBinaryMessage, serializeFrame, serializeMessage, splitBinaryFrame, splitCompactBinaryFrame, splitFrame, wireMethodName, xxh3_64, xxh3_64str };
|
package/dist/index.js
CHANGED
|
@@ -757,6 +757,17 @@ var RpcInboundCallTracker = class {
|
|
|
757
757
|
}
|
|
758
758
|
};
|
|
759
759
|
|
|
760
|
+
// src/rpc-error.ts
|
|
761
|
+
var RpcError = class extends Error {
|
|
762
|
+
typeName;
|
|
763
|
+
constructor(message, typeName) {
|
|
764
|
+
super(message);
|
|
765
|
+
this.name = "RpcError";
|
|
766
|
+
if (typeName !== void 0)
|
|
767
|
+
this.typeName = typeName;
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
760
771
|
// src/increasing-seq-compressor.ts
|
|
761
772
|
var IncreasingSeqCompressor = {
|
|
762
773
|
/**
|
|
@@ -1683,12 +1694,17 @@ var RpcSystemCallHandler = class {
|
|
|
1683
1694
|
const errorInfo = args[0];
|
|
1684
1695
|
const msg = errorInfo?.Message ?? errorInfo?.message ?? "RPC error";
|
|
1685
1696
|
const errorType = errorInfo?.TypeRef ?? errorInfo?.typeRef;
|
|
1686
|
-
|
|
1697
|
+
let typeName;
|
|
1698
|
+
if (typeof errorType === "string") {
|
|
1699
|
+
const commaIdx = errorType.indexOf(",");
|
|
1700
|
+
typeName = commaIdx >= 0 ? errorType.slice(0, commaIdx) : errorType;
|
|
1701
|
+
} else if (errorType !== null && typeof errorType === "object") {
|
|
1687
1702
|
const t = errorType;
|
|
1688
|
-
|
|
1689
|
-
warnLog5?.log("Got RpcRerouteException from remote peer:", msg);
|
|
1703
|
+
typeName = t.TypeName ?? t.typeName;
|
|
1690
1704
|
}
|
|
1691
|
-
|
|
1705
|
+
if (typeName === "ActualLab.Rpc.RpcRerouteException")
|
|
1706
|
+
warnLog5?.log("Got RpcRerouteException from remote peer:", msg);
|
|
1707
|
+
call.result.reject(new RpcError(msg, typeName));
|
|
1692
1708
|
}
|
|
1693
1709
|
break;
|
|
1694
1710
|
}
|
|
@@ -2259,6 +2275,7 @@ var RpcPeer = class {
|
|
|
2259
2275
|
this._connection = conn;
|
|
2260
2276
|
conn.messageReceived.add((raw) => this._handleMessage(raw));
|
|
2261
2277
|
conn.closed.add((ev) => {
|
|
2278
|
+
if (this._connection !== conn) return;
|
|
2262
2279
|
this._connection = void 0;
|
|
2263
2280
|
this._isConnected = false;
|
|
2264
2281
|
if (ev.reason)
|
|
@@ -2877,6 +2894,7 @@ var RpcServerPeer = class extends RpcPeer {
|
|
|
2877
2894
|
this._setConnectionState(1 /* Connecting */);
|
|
2878
2895
|
this.setupConnection(conn);
|
|
2879
2896
|
conn.closed.add(() => {
|
|
2897
|
+
if (this._connection !== conn && this._connection !== void 0) return;
|
|
2880
2898
|
this.sharedObjects.disconnectAll();
|
|
2881
2899
|
});
|
|
2882
2900
|
}
|
|
@@ -3990,6 +4008,7 @@ export {
|
|
|
3990
4008
|
RpcClientPeer,
|
|
3991
4009
|
RpcClientPeerReconnectDelayer,
|
|
3992
4010
|
RpcConnectionState,
|
|
4011
|
+
RpcError,
|
|
3993
4012
|
RpcHub,
|
|
3994
4013
|
RpcInboundCall,
|
|
3995
4014
|
RpcInboundCallTracker,
|