@actuallab/rpc 15.0.17 → 15.1.6

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.d.cts CHANGED
@@ -1213,7 +1213,8 @@ declare class RpcClientPeer extends RpcPeer {
1213
1213
  /**
1214
1214
  * Ask the server which call IDs in `eligible` it no longer recognizes
1215
1215
  * via `$sys.Reconnect:3`. Returns the set of call IDs that need to be
1216
- * resent. On any failure, falls back to "resend everything".
1216
+ * resent, or `null` if the reconciliation failed: the caller then
1217
+ * resends everything that allows it.
1217
1218
  *
1218
1219
  * Wire format of the `completedStages` argument is chosen per wire format:
1219
1220
  * - JSON (json5np): plain object `{"<stage>": "<base64-of-bytes>"}` —
package/dist/index.d.ts CHANGED
@@ -1213,7 +1213,8 @@ declare class RpcClientPeer extends RpcPeer {
1213
1213
  /**
1214
1214
  * Ask the server which call IDs in `eligible` it no longer recognizes
1215
1215
  * via `$sys.Reconnect:3`. Returns the set of call IDs that need to be
1216
- * resent. On any failure, falls back to "resend everything".
1216
+ * resent, or `null` if the reconciliation failed: the caller then
1217
+ * resends everything that allows it.
1217
1218
  *
1218
1219
  * Wire format of the `completedStages` argument is chosen per wire format:
1219
1220
  * - JSON (json5np): plain object `{"<stage>": "<base64-of-bytes>"}` —
package/dist/index.js CHANGED
@@ -900,6 +900,14 @@ var RpcError = class extends Error {
900
900
  this.typeName = typeName;
901
901
  }
902
902
  };
903
+ var CANCELLATION_TYPE_NAMES = /* @__PURE__ */ new Set([
904
+ "System.OperationCanceledException",
905
+ "System.Threading.Tasks.TaskCanceledException",
906
+ "ActualLab.Rpc.RpcRerouteException"
907
+ ]);
908
+ function isCancellationTypeName(typeName) {
909
+ return typeName !== void 0 && CANCELLATION_TYPE_NAMES.has(typeName);
910
+ }
903
911
  var REMOTE_EXCEPTION_TYPE_REF = "ActualLab.Serialization.RemoteException, ActualLab.Core";
904
912
  var genericErrorFilter = () => ({
905
913
  TypeRef: REMOTE_EXCEPTION_TYPE_REF,
@@ -1059,15 +1067,21 @@ var RpcSystemCallHandler = class {
1059
1067
  const call = peer.outboundCalls.get(relatedId);
1060
1068
  if (call !== void 0) {
1061
1069
  call.completedStage |= RpcCallStage.ResultReady;
1062
- if (call.removeOnOk) {
1070
+ const errorInfo = args[0];
1071
+ const typeName = extractTypeName(errorInfo?.TypeRef ?? errorInfo?.typeRef);
1072
+ const isCancelled = !call.removeOnOk && isCancellationTypeName(typeName);
1073
+ if (call.removeOnOk || isCancelled) {
1063
1074
  peer.outboundCalls.remove(relatedId);
1064
1075
  }
1065
- const errorInfo = args[0];
1066
1076
  const msg = errorInfo?.Message ?? errorInfo?.message ?? "RPC error";
1067
- const typeName = extractTypeName(errorInfo?.TypeRef ?? errorInfo?.typeRef);
1068
1077
  if (typeName === "ActualLab.Rpc.RpcRerouteException")
1069
1078
  warnLog4?.log("Got RpcRerouteException from remote peer:", msg);
1070
- call.result.reject(new RpcError(msg, typeName));
1079
+ const error = new RpcError(msg, typeName);
1080
+ if (isCancelled)
1081
+ error.name = "AbortError";
1082
+ call.result.reject(error);
1083
+ if (isCancelled)
1084
+ call.onDisconnect();
1071
1085
  }
1072
1086
  break;
1073
1087
  }
@@ -3493,8 +3507,10 @@ var RpcClientPeer = class extends RpcPeer {
3493
3507
  call.sentAt = Date.now();
3494
3508
  }
3495
3509
  let unknownIds = null;
3510
+ let isReconciled = false;
3496
3511
  if (!isPeerChanged && eligible.length > 0) {
3497
3512
  unknownIds = await this._reconcileReconnect(eligible, closedSignal);
3513
+ isReconciled = unknownIds !== null;
3498
3514
  }
3499
3515
  const YIELD_BATCH = 20;
3500
3516
  let resentSinceYield = 0;
@@ -3507,6 +3523,17 @@ var RpcClientPeer = class extends RpcPeer {
3507
3523
  if (unknownIds !== null && !unknownIds.has(call.callId)) {
3508
3524
  continue;
3509
3525
  }
3526
+ if (!(call.remoteExecutionMode & 4)) {
3527
+ if (!isReconciled)
3528
+ continue;
3529
+ if (!call.result.isCompleted)
3530
+ call.result.reject(new Error(
3531
+ "Outbound call failed: the peer does not know the call after reconnect and AllowResend is not set."
3532
+ ));
3533
+ call.onDisconnect();
3534
+ this.outboundCalls.remove(call.callId);
3535
+ continue;
3536
+ }
3510
3537
  call.sentAt = Date.now();
3511
3538
  this._sendWireData(call.serializedWireData);
3512
3539
  resentSinceYield++;
@@ -3519,7 +3546,8 @@ var RpcClientPeer = class extends RpcPeer {
3519
3546
  /**
3520
3547
  * Ask the server which call IDs in `eligible` it no longer recognizes
3521
3548
  * via `$sys.Reconnect:3`. Returns the set of call IDs that need to be
3522
- * resent. On any failure, falls back to "resend everything".
3549
+ * resent, or `null` if the reconciliation failed: the caller then
3550
+ * resends everything that allows it.
3523
3551
  *
3524
3552
  * Wire format of the `completedStages` argument is chosen per wire format:
3525
3553
  * - JSON (json5np): plain object `{"<stage>": "<base64-of-bytes>"}` —
@@ -3543,7 +3571,7 @@ var RpcClientPeer = class extends RpcPeer {
3543
3571
  arr.push(call.callId);
3544
3572
  }
3545
3573
  if (byStage.size === 0) {
3546
- return new Set(eligible.map((c) => c.callId));
3574
+ return null;
3547
3575
  }
3548
3576
  const isBinary = this.serializationFormat.isBinary;
3549
3577
  const stagesArg = isBinary ? /* @__PURE__ */ new Map() : {};
@@ -3567,10 +3595,10 @@ var RpcClientPeer = class extends RpcPeer {
3567
3595
  );
3568
3596
  const result = await reconnectCall.result;
3569
3597
  const bytes = _toBytes2(result);
3570
- if (bytes === null) return new Set(eligible.map((c) => c.callId));
3598
+ if (bytes === null) return null;
3571
3599
  return new Set(IncreasingSeqCompressor.deserialize(bytes));
3572
3600
  } catch {
3573
- return new Set(eligible.map((c) => c.callId));
3601
+ return null;
3574
3602
  }
3575
3603
  }
3576
3604
  /** Detects a server-peer identity change by comparing the incoming