rivetkit 3.1.2-rc.7 → 3.1.2-rc.9

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.
Files changed (83) hide show
  1. package/dist/browser/client.d.ts +4 -0
  2. package/dist/browser/client.js +64 -26
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +2 -2
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-IOQREPUK.js → chunk-24OLPBXH.js} +32 -12
  7. package/dist/tsup/chunk-24OLPBXH.js.map +1 -0
  8. package/dist/tsup/{chunk-LE3YMWAP.cjs → chunk-6BCM5FXB.cjs} +10 -10
  9. package/dist/tsup/{chunk-LE3YMWAP.cjs.map → chunk-6BCM5FXB.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-XGN6KETJ.js → chunk-7TW4LSJN.js} +2 -2
  11. package/dist/tsup/{chunk-GQKAGJK5.cjs → chunk-7YVW2AZO.cjs} +3 -3
  12. package/dist/tsup/{chunk-GQKAGJK5.cjs.map → chunk-7YVW2AZO.cjs.map} +1 -1
  13. package/dist/tsup/{chunk-FWPWI7QL.js → chunk-BAPWFPDP.js} +2 -2
  14. package/dist/tsup/{chunk-L4UTSVE3.js → chunk-C4QGTZEW.js} +3 -3
  15. package/dist/tsup/{chunk-BEXWAJ6U.cjs → chunk-DO4K3PV4.cjs} +7 -7
  16. package/dist/tsup/{chunk-BEXWAJ6U.cjs.map → chunk-DO4K3PV4.cjs.map} +1 -1
  17. package/dist/tsup/{chunk-EBFFGWLN.cjs → chunk-DWQV2G7C.cjs} +3 -3
  18. package/dist/tsup/{chunk-EBFFGWLN.cjs.map → chunk-DWQV2G7C.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-LJ6SZFME.js → chunk-F4IRT46P.js} +2 -2
  20. package/dist/tsup/{chunk-ER6SIYWL.cjs → chunk-HM7C4VY6.cjs} +174 -154
  21. package/dist/tsup/chunk-HM7C4VY6.cjs.map +1 -0
  22. package/dist/tsup/{chunk-HRSJKLCU.js → chunk-KQLEFYNT.js} +36 -18
  23. package/dist/tsup/chunk-KQLEFYNT.js.map +1 -0
  24. package/dist/tsup/{chunk-4QYXOAW5.cjs → chunk-NBYWKPR6.cjs} +4 -4
  25. package/dist/tsup/{chunk-4QYXOAW5.cjs.map → chunk-NBYWKPR6.cjs.map} +1 -1
  26. package/dist/tsup/{chunk-AH3SB6EE.cjs → chunk-SYTAFLV7.cjs} +3 -3
  27. package/dist/tsup/{chunk-AH3SB6EE.cjs.map → chunk-SYTAFLV7.cjs.map} +1 -1
  28. package/dist/tsup/{chunk-N6GT7FYD.js → chunk-U7RFRYY2.js} +2 -2
  29. package/dist/tsup/{chunk-DOJBNDVS.cjs → chunk-V7ISUWSD.cjs} +36 -18
  30. package/dist/tsup/chunk-V7ISUWSD.cjs.map +1 -0
  31. package/dist/tsup/{chunk-NWQJIAG4.js → chunk-VYXFJR7Y.js} +4 -4
  32. package/dist/tsup/client/mod.cjs +5 -5
  33. package/dist/tsup/client/mod.d.cts +2 -2
  34. package/dist/tsup/client/mod.d.ts +2 -2
  35. package/dist/tsup/client/mod.js +4 -4
  36. package/dist/tsup/common/log.cjs +2 -2
  37. package/dist/tsup/common/log.js +1 -1
  38. package/dist/tsup/common/websocket.cjs +3 -3
  39. package/dist/tsup/common/websocket.js +2 -2
  40. package/dist/tsup/{config-CyOAiV6S.d.cts → config-B1L9Ytm_.d.cts} +4 -0
  41. package/dist/tsup/{config-TS1eu7w9.d.ts → config-DhGSJx-3.d.ts} +4 -0
  42. package/dist/tsup/{context-CxYw0sLz.d.ts → context-B6HOPYyk.d.ts} +1 -1
  43. package/dist/tsup/{context-Cq5UEIVG.d.cts → context-BuQ4FncM.d.cts} +1 -1
  44. package/dist/tsup/db/drizzle.cjs +2 -2
  45. package/dist/tsup/db/drizzle.js +1 -1
  46. package/dist/tsup/db/mod.cjs +3 -3
  47. package/dist/tsup/db/mod.js +2 -2
  48. package/dist/tsup/dynamic/mod.d.cts +1 -1
  49. package/dist/tsup/dynamic/mod.d.ts +1 -1
  50. package/dist/tsup/inspector/mod.cjs +5 -5
  51. package/dist/tsup/inspector/mod.js +4 -4
  52. package/dist/tsup/inspector/workflow.cjs +4 -4
  53. package/dist/tsup/inspector/workflow.js +3 -3
  54. package/dist/tsup/inspector-tab/mod.d.cts +2 -2
  55. package/dist/tsup/inspector-tab/mod.d.ts +2 -2
  56. package/dist/tsup/mod.cjs +86 -86
  57. package/dist/tsup/mod.d.cts +3 -3
  58. package/dist/tsup/mod.d.ts +3 -3
  59. package/dist/tsup/mod.js +5 -5
  60. package/dist/tsup/test/mod.cjs +6 -6
  61. package/dist/tsup/test/mod.d.cts +1 -1
  62. package/dist/tsup/test/mod.d.ts +1 -1
  63. package/dist/tsup/test/mod.js +4 -4
  64. package/dist/tsup/utils.cjs +2 -2
  65. package/dist/tsup/utils.js +1 -1
  66. package/dist/tsup/workflow/mod.cjs +7 -7
  67. package/dist/tsup/workflow/mod.d.cts +3 -3
  68. package/dist/tsup/workflow/mod.d.ts +3 -3
  69. package/dist/tsup/workflow/mod.js +4 -4
  70. package/package.json +10 -10
  71. package/src/client/actor-conn.ts +33 -9
  72. package/src/client/lifecycle-errors.ts +3 -1
  73. package/src/common/encoding.ts +45 -15
  74. package/dist/tsup/chunk-DOJBNDVS.cjs.map +0 -1
  75. package/dist/tsup/chunk-ER6SIYWL.cjs.map +0 -1
  76. package/dist/tsup/chunk-HRSJKLCU.js.map +0 -1
  77. package/dist/tsup/chunk-IOQREPUK.js.map +0 -1
  78. /package/dist/tsup/{chunk-XGN6KETJ.js.map → chunk-7TW4LSJN.js.map} +0 -0
  79. /package/dist/tsup/{chunk-FWPWI7QL.js.map → chunk-BAPWFPDP.js.map} +0 -0
  80. /package/dist/tsup/{chunk-L4UTSVE3.js.map → chunk-C4QGTZEW.js.map} +0 -0
  81. /package/dist/tsup/{chunk-LJ6SZFME.js.map → chunk-F4IRT46P.js.map} +0 -0
  82. /package/dist/tsup/{chunk-N6GT7FYD.js.map → chunk-U7RFRYY2.js.map} +0 -0
  83. /package/dist/tsup/{chunk-NWQJIAG4.js.map → chunk-VYXFJR7Y.js.map} +0 -0
@@ -1184,6 +1184,10 @@ declare class ActorConnRaw {
1184
1184
  /**
1185
1185
  * Call a raw action connection. See {@link ActorConn} for type-safe action calls.
1186
1186
  *
1187
+ * Aborting `signal` rejects the call with `signal.reason`. An action still queued while the
1188
+ * connection opens or reconnects is dropped and never sent. An action already sent may
1189
+ * still run on the actor.
1190
+ *
1187
1191
  * @see {@link ActorConn}
1188
1192
  * @template Args - The type of arguments to pass to the action function.
1189
1193
  * @template Response - The type of the response returned by the action function.
@@ -230,7 +230,7 @@ function noopNext() {
230
230
  // package.json
231
231
  var package_default = {
232
232
  name: "rivetkit",
233
- version: "3.1.2-rc.7",
233
+ version: "3.1.2-rc.9",
234
234
  description: "Lightweight libraries for building stateful actors on edge platforms",
235
235
  license: "Apache-2.0",
236
236
  keywords: [
@@ -450,7 +450,7 @@ var package_default = {
450
450
  "@rivetkit/traces": "workspace:*",
451
451
  "@rivetkit/virtual-websocket": "workspace:*",
452
452
  "@rivetkit/workflow-engine": "workspace:*",
453
- "cbor-x": "^1.6.0",
453
+ "cbor-x": "^1.6.6",
454
454
  "drizzle-orm": "catalog:",
455
455
  hono: "^4.7.0",
456
456
  invariant: "^2.2.4",
@@ -699,21 +699,31 @@ function encodeJsonCompatValue(input) {
699
699
  throw new TypeError(`Value of type "${typeName}" is not CBOR serializable`);
700
700
  }
701
701
  function reviveJsonCompatValue(input, options = {}) {
702
+ return reviveValue(input, options, /* @__PURE__ */ new WeakMap());
703
+ }
704
+ function reviveValue(input, options, revived) {
702
705
  if (typeof input === "bigint") {
703
706
  if (options.coerceSafeIntegerBigInts && input >= BigInt(Number.MIN_SAFE_INTEGER) && input <= BigInt(Number.MAX_SAFE_INTEGER)) {
704
707
  return Number(input);
705
708
  }
706
709
  return input;
707
710
  }
711
+ if (typeof input !== "object" || input === null) {
712
+ return input;
713
+ }
714
+ if (revived.has(input)) {
715
+ return revived.get(input);
716
+ }
708
717
  if (input instanceof Map) {
709
- const revived = /* @__PURE__ */ new Map();
718
+ const map = /* @__PURE__ */ new Map();
719
+ revived.set(input, map);
710
720
  for (const [k, v] of input.entries()) {
711
- revived.set(
712
- reviveJsonCompatValue(k, options),
713
- reviveJsonCompatValue(v, options)
721
+ map.set(
722
+ reviveValue(k, options, revived),
723
+ reviveValue(v, options, revived)
714
724
  );
715
725
  }
716
- return revived;
726
+ return map;
717
727
  }
718
728
  if (Array.isArray(input)) {
719
729
  if (input.length === 2 && typeof input[0] === "string" && input[0].startsWith("$")) {
@@ -730,27 +740,35 @@ function reviveJsonCompatValue(input, options = {}) {
730
740
  return void 0;
731
741
  }
732
742
  if (input[0] === JSON_COMPAT_SET) {
733
- const items = input[1].map(
734
- (v) => reviveJsonCompatValue(v, options)
735
- );
736
- return new Set(items);
743
+ const set = /* @__PURE__ */ new Set();
744
+ revived.set(input, set);
745
+ for (const value of input[1]) {
746
+ set.add(reviveValue(value, options, revived));
747
+ }
748
+ return set;
737
749
  }
738
750
  if (input[0].startsWith("$$")) {
739
- return [
740
- input[0].substring(1),
741
- reviveJsonCompatValue(input[1], options)
742
- ];
751
+ const escaped = [input[0].substring(1)];
752
+ revived.set(input, escaped);
753
+ escaped.push(reviveValue(input[1], options, revived));
754
+ return escaped;
743
755
  }
744
756
  throw new Error(
745
757
  `Unknown JSON encoding type: ${input[0]}. This may indicate corrupted data or a version mismatch.`
746
758
  );
747
759
  }
748
- return input.map((value) => reviveJsonCompatValue(value, options));
760
+ const array = [];
761
+ revived.set(input, array);
762
+ for (const value of input) {
763
+ array.push(reviveValue(value, options, revived));
764
+ }
765
+ return array;
749
766
  }
750
767
  if (isPlainObject(input)) {
751
768
  const decoded = {};
769
+ revived.set(input, decoded);
752
770
  for (const [key, value] of Object.entries(input)) {
753
- decoded[key] = reviveJsonCompatValue(value, options);
771
+ decoded[key] = reviveValue(value, options, revived);
754
772
  }
755
773
  return decoded;
756
774
  }
@@ -4998,7 +5016,7 @@ function classifyActorError(error) {
4998
5016
  { group: error.group, code: error.code }
4999
5017
  );
5000
5018
  }
5001
- if (error.group === "ups" && error.code === "consumer_closed" || error.group === "depot" && error.code === "request_deadline_exceeded") {
5019
+ if (error.group === "ups" && error.code === "consumer_closed" || error.group === "depot" && (error.code === "request_deadline_exceeded" || error.code === "unavailable")) {
5002
5020
  return buildLifecycleBoundaryInfo(
5003
5021
  "reconnect_only",
5004
5022
  "actor_error",
@@ -5463,6 +5481,10 @@ var ActorConnRaw = class {
5463
5481
  /**
5464
5482
  * Call a raw action connection. See {@link ActorConn} for type-safe action calls.
5465
5483
  *
5484
+ * Aborting `signal` rejects the call with `signal.reason`. An action still queued while the
5485
+ * connection opens or reconnects is dropped and never sent. An action already sent may
5486
+ * still run on the actor.
5487
+ *
5466
5488
  * @see {@link ActorConn}
5467
5489
  * @template Args - The type of arguments to pass to the action function.
5468
5490
  * @template Response - The type of the response returned by the action function.
@@ -5476,6 +5498,8 @@ var ActorConnRaw = class {
5476
5498
  `Invalid action call: expected an options object { name, args }, got ${typeof opts}. Use conn.actionName(...args) for the shorthand API.`
5477
5499
  );
5478
5500
  }
5501
+ const signal = opts.signal;
5502
+ if (signal?.aborted) throw signal.reason;
5479
5503
  if (this.#disposed) throw new ActorConnDisposed();
5480
5504
  if (this.#connectionOpenError) throw this.#connectionOpenError;
5481
5505
  logger2().debug({ msg: "action", name: opts.name, args: opts.args });
@@ -5493,7 +5517,7 @@ var ActorConnRaw = class {
5493
5517
  actionName: opts.name,
5494
5518
  inFlightCount: this.#actionsInFlight.size
5495
5519
  });
5496
- this.#sendMessage({
5520
+ const message = {
5497
5521
  body: {
5498
5522
  tag: "ActionRequest",
5499
5523
  val: {
@@ -5502,13 +5526,27 @@ var ActorConnRaw = class {
5502
5526
  args: opts.args
5503
5527
  }
5504
5528
  }
5505
- });
5506
- const { id: responseId, output } = await promise;
5507
- if (responseId !== BigInt(actionId))
5508
- throw new Error(
5509
- `Request ID ${actionId} does not match response ID ${responseId}`
5510
- );
5511
- return output;
5529
+ };
5530
+ this.#sendMessage(message);
5531
+ const onAbort = () => {
5532
+ const queuedIndex = this.#messageQueue.indexOf(message);
5533
+ if (queuedIndex !== -1) {
5534
+ this.#messageQueue.splice(queuedIndex, 1);
5535
+ this.#actionsInFlight.delete(actionId);
5536
+ }
5537
+ reject(signal?.reason);
5538
+ };
5539
+ signal?.addEventListener("abort", onAbort, { once: true });
5540
+ try {
5541
+ const { id: responseId, output } = await promise;
5542
+ if (responseId !== BigInt(actionId))
5543
+ throw new Error(
5544
+ `Request ID ${actionId} does not match response ID ${responseId}`
5545
+ );
5546
+ return output;
5547
+ } finally {
5548
+ signal?.removeEventListener("abort", onAbort);
5549
+ }
5512
5550
  }
5513
5551
  /**
5514
5552
  * Do not call this directly.