rivetkit 3.1.2-rc.6 → 3.1.2-rc.7

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 (103) hide show
  1. package/dist/browser/client.d.ts +2 -30
  2. package/dist/browser/client.js +56 -39
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/tsup/{chunk-KCL4AISR.cjs → chunk-4QYXOAW5.cjs} +4 -4
  7. package/dist/tsup/{chunk-KCL4AISR.cjs.map → chunk-4QYXOAW5.cjs.map} +1 -1
  8. package/dist/tsup/{chunk-V32FXQ3Y.cjs → chunk-AH3SB6EE.cjs} +3 -3
  9. package/dist/tsup/{chunk-V32FXQ3Y.cjs.map → chunk-AH3SB6EE.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-X3EPJHTD.cjs → chunk-BEXWAJ6U.cjs} +7 -7
  11. package/dist/tsup/{chunk-X3EPJHTD.cjs.map → chunk-BEXWAJ6U.cjs.map} +1 -1
  12. package/dist/tsup/{chunk-JHBRUK2G.cjs → chunk-DOJBNDVS.cjs} +5 -3
  13. package/dist/tsup/chunk-DOJBNDVS.cjs.map +1 -0
  14. package/dist/tsup/{chunk-NHTD4LYE.cjs → chunk-EBFFGWLN.cjs} +3 -3
  15. package/dist/tsup/{chunk-NHTD4LYE.cjs.map → chunk-EBFFGWLN.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-7EDYE6RS.cjs → chunk-ER6SIYWL.cjs} +196 -181
  17. package/dist/tsup/chunk-ER6SIYWL.cjs.map +1 -0
  18. package/dist/tsup/{chunk-GPNKYTKX.js → chunk-FWPWI7QL.js} +2 -2
  19. package/dist/tsup/{chunk-AKADRXK5.cjs → chunk-GQKAGJK5.cjs} +3 -3
  20. package/dist/tsup/{chunk-AKADRXK5.cjs.map → chunk-GQKAGJK5.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-2OEJM5K3.js → chunk-HRSJKLCU.js} +5 -3
  22. package/dist/tsup/{chunk-2OEJM5K3.js.map → chunk-HRSJKLCU.js.map} +1 -1
  23. package/dist/tsup/{chunk-O6BVKXY4.js → chunk-IOQREPUK.js} +55 -40
  24. package/dist/tsup/chunk-IOQREPUK.js.map +1 -0
  25. package/dist/tsup/{chunk-Y5RH2IT6.js → chunk-L4UTSVE3.js} +3 -3
  26. package/dist/tsup/{chunk-X7HD5E4N.cjs → chunk-LE3YMWAP.cjs} +10 -10
  27. package/dist/tsup/{chunk-X7HD5E4N.cjs.map → chunk-LE3YMWAP.cjs.map} +1 -1
  28. package/dist/tsup/{chunk-4GCDILHQ.js → chunk-LJ6SZFME.js} +2 -2
  29. package/dist/tsup/{chunk-HEWH252Y.js → chunk-N6GT7FYD.js} +2 -2
  30. package/dist/tsup/{chunk-AUC22H3Q.js → chunk-NWQJIAG4.js} +4 -4
  31. package/dist/tsup/{chunk-LFGYDRKK.js → chunk-XGN6KETJ.js} +2 -2
  32. package/dist/tsup/client/mod.cjs +5 -5
  33. package/dist/tsup/client/mod.d.cts +4 -4
  34. package/dist/tsup/client/mod.d.ts +4 -4
  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-BMGUEKMZ.d.cts → config-CyOAiV6S.d.cts} +3 -31
  41. package/dist/tsup/{config-iBpXyITj.d.ts → config-TS1eu7w9.d.ts} +3 -31
  42. package/dist/tsup/{context-qfvLuF0P.d.cts → context-Cq5UEIVG.d.cts} +1 -1
  43. package/dist/tsup/{context-hyVakgnU.d.ts → context-CxYw0sLz.d.ts} +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 +2 -2
  49. package/dist/tsup/dynamic/mod.d.ts +2 -2
  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 +3 -3
  55. package/dist/tsup/inspector-tab/mod.d.ts +3 -3
  56. package/dist/tsup/mod.cjs +127 -391
  57. package/dist/tsup/mod.cjs.map +1 -1
  58. package/dist/tsup/mod.d.cts +4 -4
  59. package/dist/tsup/mod.d.ts +4 -4
  60. package/dist/tsup/mod.js +46 -310
  61. package/dist/tsup/mod.js.map +1 -1
  62. package/dist/tsup/test/mod.cjs +6 -6
  63. package/dist/tsup/test/mod.d.cts +2 -2
  64. package/dist/tsup/test/mod.d.ts +2 -2
  65. package/dist/tsup/test/mod.js +4 -4
  66. package/dist/tsup/{utils-C6b0aYUM.d.cts → utils-BctYATXG.d.cts} +4 -1
  67. package/dist/tsup/{utils-C1O-SklO.d.ts → utils-CR1Y49t6.d.ts} +4 -1
  68. package/dist/tsup/utils.cjs +2 -2
  69. package/dist/tsup/utils.d.cts +1 -1
  70. package/dist/tsup/utils.d.ts +1 -1
  71. package/dist/tsup/utils.js +1 -1
  72. package/dist/tsup/workflow/mod.cjs +7 -7
  73. package/dist/tsup/workflow/mod.d.cts +4 -4
  74. package/dist/tsup/workflow/mod.d.ts +4 -4
  75. package/dist/tsup/workflow/mod.js +4 -4
  76. package/package.json +9 -9
  77. package/src/client/actor-conn.ts +6 -7
  78. package/src/client/actor-handle.ts +1 -0
  79. package/src/client/client.ts +4 -1
  80. package/src/client/lifecycle-errors.ts +38 -0
  81. package/src/client/query.ts +4 -4
  82. package/src/client/resolve-gateway-target.ts +34 -15
  83. package/src/common/database/config.ts +0 -52
  84. package/src/common/database/native-database.ts +18 -229
  85. package/src/engine-api/actors.ts +0 -2
  86. package/src/engine-client/driver.ts +1 -3
  87. package/src/engine-client/mod.ts +1 -11
  88. package/src/registry/config/index.ts +3 -1
  89. package/src/registry/index.ts +15 -14
  90. package/src/registry/napi-runtime.ts +2 -81
  91. package/src/registry/native.ts +17 -66
  92. package/src/registry/runtime.ts +2 -53
  93. package/src/registry/wasm-runtime.ts +0 -88
  94. package/src/utils.ts +7 -2
  95. package/dist/tsup/chunk-7EDYE6RS.cjs.map +0 -1
  96. package/dist/tsup/chunk-JHBRUK2G.cjs.map +0 -1
  97. package/dist/tsup/chunk-O6BVKXY4.js.map +0 -1
  98. /package/dist/tsup/{chunk-GPNKYTKX.js.map → chunk-FWPWI7QL.js.map} +0 -0
  99. /package/dist/tsup/{chunk-Y5RH2IT6.js.map → chunk-L4UTSVE3.js.map} +0 -0
  100. /package/dist/tsup/{chunk-4GCDILHQ.js.map → chunk-LJ6SZFME.js.map} +0 -0
  101. /package/dist/tsup/{chunk-HEWH252Y.js.map → chunk-N6GT7FYD.js.map} +0 -0
  102. /package/dist/tsup/{chunk-AUC22H3Q.js.map → chunk-NWQJIAG4.js.map} +0 -0
  103. /package/dist/tsup/{chunk-LFGYDRKK.js.map → chunk-XGN6KETJ.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  importWebSocket,
8
8
  logger
9
- } from "./chunk-GPNKYTKX.js";
9
+ } from "./chunk-FWPWI7QL.js";
10
10
  import {
11
11
  AsyncMutex
12
12
  } from "./chunk-JTHHCZCZ.js";
@@ -36,7 +36,7 @@ import {
36
36
  serializeWithEncoding,
37
37
  stringifyError,
38
38
  uint8ArrayToBase64
39
- } from "./chunk-2OEJM5K3.js";
39
+ } from "./chunk-HRSJKLCU.js";
40
40
  import {
41
41
  INTERNAL_ERROR_CODE,
42
42
  RivetError,
@@ -2276,6 +2276,14 @@ function classifyActorError(error) {
2276
2276
  }
2277
2277
  );
2278
2278
  }
2279
+ if (error.group === "sqlite" && error.code === "storage_overloaded" || error.group === "depot" && error.code === "overloaded") {
2280
+ return buildLifecycleBoundaryInfo(
2281
+ "reconnect_only",
2282
+ "actor_error",
2283
+ error.message,
2284
+ { group: error.group, code: error.code }
2285
+ );
2286
+ }
2279
2287
  if (error.group === "ups" && error.code === "consumer_closed" || error.group === "depot" && error.code === "request_deadline_exceeded") {
2280
2288
  return buildLifecycleBoundaryInfo(
2281
2289
  "reconnect_only",
@@ -2432,6 +2440,15 @@ function isRetryableForkRefusal(error) {
2432
2440
  }
2433
2441
  return false;
2434
2442
  }
2443
+ function isRetryableCreateRefusal(error) {
2444
+ if (isRetryableLifecycleRequestError(error)) {
2445
+ return true;
2446
+ }
2447
+ if (!(error instanceof RivetError) || retryAfterMs(error) === void 0) {
2448
+ return false;
2449
+ }
2450
+ return error.group === "depot" && (error.code === "overloaded" || error.code === "read_interrupted") || error.group === "guard" && error.code === "service_unavailable" || error.group === "namespace" && error.code === "creating";
2451
+ }
2435
2452
  async function retryOnLifecycleBoundary(run, opts) {
2436
2453
  var _a;
2437
2454
  const maxAttempts = (opts == null ? void 0 : opts.maxAttempts) ?? 5;
@@ -2926,7 +2943,12 @@ async function rawWebSocket(driver, target, params, path, _protocols, options =
2926
2943
  }
2927
2944
 
2928
2945
  // src/client/resolve-gateway-target.ts
2929
- async function resolveGatewayTarget(driver, target) {
2946
+ async function resolveGatewayTarget(driver, target, opts) {
2947
+ const retryCreate = (run) => retryOnLifecycleBoundary(run, {
2948
+ signal: opts == null ? void 0 : opts.signal,
2949
+ budget: opts == null ? void 0 : opts.budget,
2950
+ isRetryable: isRetryableCreateRefusal
2951
+ });
2930
2952
  if ("directId" in target) {
2931
2953
  return target.directId;
2932
2954
  }
@@ -2946,23 +2968,27 @@ async function resolveGatewayTarget(driver, target) {
2946
2968
  return output.actorId;
2947
2969
  }
2948
2970
  if ("getOrCreateForKey" in target) {
2949
- const output = await driver.getOrCreateWithKey({
2950
- name: target.getOrCreateForKey.name,
2951
- key: target.getOrCreateForKey.key,
2952
- input: target.getOrCreateForKey.input,
2953
- region: target.getOrCreateForKey.region,
2954
- poolName: target.getOrCreateForKey.poolName
2955
- });
2971
+ const output = await retryCreate(
2972
+ () => driver.getOrCreateWithKey({
2973
+ name: target.getOrCreateForKey.name,
2974
+ key: target.getOrCreateForKey.key,
2975
+ input: target.getOrCreateForKey.input,
2976
+ region: target.getOrCreateForKey.region,
2977
+ poolName: target.getOrCreateForKey.poolName
2978
+ })
2979
+ );
2956
2980
  return output.actorId;
2957
2981
  }
2958
2982
  if ("create" in target) {
2959
- const output = await driver.createActor({
2960
- name: target.create.name,
2961
- key: target.create.key,
2962
- input: target.create.input,
2963
- region: target.create.region,
2964
- poolName: target.create.poolName
2965
- });
2983
+ const output = await retryCreate(
2984
+ () => driver.createActor({
2985
+ name: target.create.name,
2986
+ key: target.create.key,
2987
+ input: target.create.input,
2988
+ region: target.create.region,
2989
+ poolName: target.create.poolName
2990
+ })
2991
+ );
2966
2992
  return output.actorId;
2967
2993
  }
2968
2994
  throw invalidRequest("Invalid query format");
@@ -3390,7 +3416,8 @@ var ActorHandleRaw = class {
3390
3416
  if (!this.#resolvingActorId) {
3391
3417
  this.#resolvingActorId = resolveGatewayTarget(
3392
3418
  this.#driver,
3393
- this.#actorResolutionState
3419
+ this.#actorResolutionState,
3420
+ { budget: this.#retryBudget, signal: this.#signal }
3394
3421
  ).then((actorId) => {
3395
3422
  this.#resolvedActorId = actorId;
3396
3423
  return actorId;
@@ -3865,7 +3892,10 @@ var ClientRaw = class {
3865
3892
  parameters: opts == null ? void 0 : opts.params,
3866
3893
  create: createQuery.create
3867
3894
  });
3868
- const actorId = await resolveGatewayTarget(this.#driver, createQuery);
3895
+ const actorId = await resolveGatewayTarget(this.#driver, createQuery, {
3896
+ budget: this.#retryBudget,
3897
+ signal: opts == null ? void 0 : opts.signal
3898
+ });
3869
3899
  logger().debug({
3870
3900
  msg: "created actor with ID",
3871
3901
  name,
@@ -4290,12 +4320,7 @@ var ActorConnRaw = class {
4290
4320
  logger().debug({ msg: "action", name: opts.name, args: opts.args });
4291
4321
  const actionId = this.#actionIdCounter;
4292
4322
  this.#actionIdCounter += 1;
4293
- const { promise, resolve, reject } = promiseWithResolvers(
4294
- (reason) => logger().warn({
4295
- msg: "unhandled action promise rejection",
4296
- reason
4297
- })
4298
- );
4323
+ const { promise, resolve, reject } = promiseWithResolvers();
4299
4324
  this.#actionsInFlight.set(actionId, {
4300
4325
  name: opts.name,
4301
4326
  resolve,
@@ -4849,7 +4874,7 @@ var ActorConnRaw = class {
4849
4874
  error = new RivetError(
4850
4875
  group,
4851
4876
  code,
4852
- `Connection closed: ${reason}`,
4877
+ group === "guard" && code === "service_unavailable" && retryAfterMs2 !== void 0 ? `The gateway could not open the actor connection. RivetKit will retry automatically after at least ${retryAfterMs2} ms. If connection failures increase with load, reduce concurrent connection attempts and ramp up gradually. If they persist at low load, ask your cluster operator to check gateway and storage health.` : `Connection closed: ${reason}`,
4853
4878
  closeOptions
4854
4879
  );
4855
4880
  }
@@ -6386,14 +6411,7 @@ var RemoteEngineControlClient = class {
6386
6411
  }
6387
6412
  async getOrCreateWithKey(input) {
6388
6413
  await this.#metadataPromise;
6389
- const {
6390
- name,
6391
- key,
6392
- input: actorInput,
6393
- region,
6394
- crashPolicy,
6395
- poolName
6396
- } = input;
6414
+ const { name, key, input: actorInput, region, poolName } = input;
6397
6415
  logger2().info({
6398
6416
  msg: "getOrCreateWithKey: getting or creating actor via engine api",
6399
6417
  name,
@@ -6408,8 +6426,7 @@ var RemoteEngineControlClient = class {
6408
6426
  pool: poolName ?? this.#config.poolName,
6409
6427
  input: actorInput ? uint8ArrayToBase64(
6410
6428
  encodeCborCompat(actorInput)
6411
- ) : void 0,
6412
- crash_policy: crashPolicy ?? "sleep"
6429
+ ) : void 0
6413
6430
  })
6414
6431
  );
6415
6432
  logger2().info({
@@ -6449,7 +6466,6 @@ var RemoteEngineControlClient = class {
6449
6466
  key,
6450
6467
  input,
6451
6468
  region,
6452
- crashPolicy,
6453
6469
  poolName
6454
6470
  }) {
6455
6471
  await this.#metadataPromise;
@@ -6462,8 +6478,7 @@ var RemoteEngineControlClient = class {
6462
6478
  key: serializeActorKey(key),
6463
6479
  input: input ? uint8ArrayToBase64(
6464
6480
  encodeCborCompat(input)
6465
- ) : void 0,
6466
- crash_policy: crashPolicy ?? "sleep"
6481
+ ) : void 0
6467
6482
  })
6468
6483
  );
6469
6484
  logger2().info({
@@ -6744,4 +6759,4 @@ export {
6744
6759
  updateRunnerConfig,
6745
6760
  RemoteEngineControlClient
6746
6761
  };
6747
- //# sourceMappingURL=chunk-O6BVKXY4.js.map
6762
+ //# sourceMappingURL=chunk-IOQREPUK.js.map