rivetkit 0.0.0-pr.4738.bcfa930 → 0.0.0-pr.4742.801cfc2

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 (58) hide show
  1. package/dist/browser/client.js +40 -67
  2. package/dist/browser/client.js.map +1 -1
  3. package/dist/browser/inspector/client.js +1 -1
  4. package/dist/browser/inspector/client.js.map +1 -1
  5. package/dist/tsup/{chunk-GWP4VNI7.js → chunk-BTVUK3IC.js} +2 -2
  6. package/dist/tsup/{chunk-QGDWYYD7.js → chunk-CPCJEWLG.js} +2 -2
  7. package/dist/tsup/{chunk-J33Q7PGH.js → chunk-HEM62MDA.js} +2 -2
  8. package/dist/tsup/{chunk-MUCRIHJ6.cjs → chunk-HVPKXOID.cjs} +10 -10
  9. package/dist/tsup/{chunk-MUCRIHJ6.cjs.map → chunk-HVPKXOID.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-CLPFFUWW.cjs → chunk-ICDDRXJS.cjs} +3 -3
  11. package/dist/tsup/{chunk-CLPFFUWW.cjs.map → chunk-ICDDRXJS.cjs.map} +1 -1
  12. package/dist/tsup/{chunk-4A47NQEH.cjs → chunk-OLOYUPA6.cjs} +4 -4
  13. package/dist/tsup/{chunk-4A47NQEH.cjs.map → chunk-OLOYUPA6.cjs.map} +1 -1
  14. package/dist/tsup/{chunk-P5AHBGWA.cjs → chunk-P3Z4AUWI.cjs} +5 -5
  15. package/dist/tsup/{chunk-P5AHBGWA.cjs.map → chunk-P3Z4AUWI.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-M4I2U45O.cjs → chunk-PJ36ACNZ.cjs} +2 -2
  17. package/dist/tsup/{chunk-M4I2U45O.cjs.map → chunk-PJ36ACNZ.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-NZ5ONF6T.js → chunk-RWBQVVA2.js} +3 -3
  19. package/dist/tsup/{chunk-HIRLQFEA.js → chunk-VW3WJVPX.js} +2 -2
  20. package/dist/tsup/{chunk-HIRLQFEA.js.map → chunk-VW3WJVPX.js.map} +1 -1
  21. package/dist/tsup/{chunk-WSJO4KXA.js → chunk-WN6AYTP7.js} +4 -4
  22. package/dist/tsup/{chunk-GSAIQ5SH.cjs → chunk-Z7SJ5DMQ.cjs} +8 -8
  23. package/dist/tsup/{chunk-GSAIQ5SH.cjs.map → chunk-Z7SJ5DMQ.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-36N4HPSL.cjs → chunk-ZKKHIBYA.cjs} +173 -200
  25. package/dist/tsup/chunk-ZKKHIBYA.cjs.map +1 -0
  26. package/dist/tsup/{chunk-G2Z5FGYT.js → chunk-ZMGUGK3U.js} +43 -70
  27. package/dist/tsup/chunk-ZMGUGK3U.js.map +1 -0
  28. package/dist/tsup/client/mod.cjs +6 -6
  29. package/dist/tsup/client/mod.js +5 -5
  30. package/dist/tsup/common/log.cjs +2 -2
  31. package/dist/tsup/common/log.js +1 -1
  32. package/dist/tsup/common/websocket.cjs +3 -3
  33. package/dist/tsup/common/websocket.js +2 -2
  34. package/dist/tsup/inspector/mod.cjs +5 -5
  35. package/dist/tsup/inspector/mod.js +4 -4
  36. package/dist/tsup/mod.cjs +97 -76
  37. package/dist/tsup/mod.cjs.map +1 -1
  38. package/dist/tsup/mod.js +54 -33
  39. package/dist/tsup/mod.js.map +1 -1
  40. package/dist/tsup/test/mod.cjs +9 -9
  41. package/dist/tsup/test/mod.js +5 -5
  42. package/dist/tsup/utils.cjs +2 -2
  43. package/dist/tsup/utils.js +1 -1
  44. package/dist/tsup/workflow/mod.cjs +7 -7
  45. package/dist/tsup/workflow/mod.js +4 -4
  46. package/package.json +7 -7
  47. package/src/client/actor-conn.ts +9 -16
  48. package/src/client/actor-handle.ts +32 -69
  49. package/src/client/actor-query.ts +1 -3
  50. package/src/common/database/native-database.ts +43 -17
  51. package/src/registry/native.ts +9 -13
  52. package/dist/tsup/chunk-36N4HPSL.cjs.map +0 -1
  53. package/dist/tsup/chunk-G2Z5FGYT.js.map +0 -1
  54. /package/dist/tsup/{chunk-GWP4VNI7.js.map → chunk-BTVUK3IC.js.map} +0 -0
  55. /package/dist/tsup/{chunk-QGDWYYD7.js.map → chunk-CPCJEWLG.js.map} +0 -0
  56. /package/dist/tsup/{chunk-J33Q7PGH.js.map → chunk-HEM62MDA.js.map} +0 -0
  57. /package/dist/tsup/{chunk-NZ5ONF6T.js.map → chunk-RWBQVVA2.js.map} +0 -0
  58. /package/dist/tsup/{chunk-WSJO4KXA.js.map → chunk-WN6AYTP7.js.map} +0 -0
@@ -225,7 +225,7 @@ function noopNext() {
225
225
  // package.json
226
226
  var package_default = {
227
227
  name: "rivetkit",
228
- version: "0.0.0-pr.4738.bcfa930",
228
+ version: "0.0.0-pr.4742.801cfc2",
229
229
  description: "Lightweight libraries for building stateful actors on edge platforms",
230
230
  license: "Apache-2.0",
231
231
  keywords: [
@@ -3699,8 +3699,8 @@ function getGatewayTarget(state) {
3699
3699
  }
3700
3700
  return state;
3701
3701
  }
3702
- function isStaleResolvedActorError(group, code, message) {
3703
- return group === "actor" && (code === "not_found" || code === "stopping" || code === "not_configured" && message === "Actor capability 'actor event inbox' is not configured." || code.startsWith("destroyed_"));
3702
+ function isStaleResolvedActorError(group, code) {
3703
+ return group === "actor" && (code === "not_found" || code === "starting" || code === "stopping" || code.startsWith("destroyed_"));
3704
3704
  }
3705
3705
  async function checkForSchedulingError(group, code, actorId, query, driver) {
3706
3706
  const name = getActorNameFromQuery(query);
@@ -3857,20 +3857,21 @@ var ActorConnRaw = class {
3857
3857
  }
3858
3858
  /**
3859
3859
  * If the query is dynamic (getForKey or getOrCreateForKey) and the error
3860
- * indicates the previously resolved actor is gone (not_found or destroyed),
3860
+ * indicates the previously resolved actor is stale (not_found, starting,
3861
+ * stopping, or destroyed),
3861
3862
  * clear the cached actor ID and connection ID so the next operation
3862
3863
  * re-resolves to a fresh actor. Returns true if the identity was
3863
3864
  * invalidated.
3864
3865
  */
3865
- #invalidateActorIfStale(group, code, message) {
3866
- if (!isDynamicActorQuery(this.#actorResolutionState) || !isStaleResolvedActorError(group, code, message)) {
3866
+ #invalidateActorIfStale(group, code) {
3867
+ if (!isDynamicActorQuery(this.#actorResolutionState) || !isStaleResolvedActorError(group, code)) {
3867
3868
  return false;
3868
3869
  }
3869
3870
  this.#clearResolvedActorIdentity();
3870
3871
  return true;
3871
3872
  }
3872
- #shouldReconnectForStaleActor(group, code, message) {
3873
- return isDynamicActorQuery(this.#actorResolutionState) && isStaleResolvedActorError(group, code, message) && this.#onOpenPromise !== void 0 && this.#connStatus !== "connected";
3873
+ #shouldReconnectForStaleActor(group, code) {
3874
+ return isDynamicActorQuery(this.#actorResolutionState) && isStaleResolvedActorError(group, code) && this.#onOpenPromise !== void 0 && this.#connStatus !== "connected";
3874
3875
  }
3875
3876
  send(name, body, options) {
3876
3877
  return this.#sendQueueMessage(name, body, options);
@@ -4184,7 +4185,7 @@ var ActorConnRaw = class {
4184
4185
  const { group, code, message, metadata, actionId } = response.body.val;
4185
4186
  if (actionId !== null) {
4186
4187
  const inFlight = this.#takeActionInFlight(Number(actionId));
4187
- this.#invalidateActorIfStale(group, code, message);
4188
+ this.#invalidateActorIfStale(group, code);
4188
4189
  logger2().warn({
4189
4190
  msg: "action error",
4190
4191
  actionId,
@@ -4205,7 +4206,7 @@ var ActorConnRaw = class {
4205
4206
  message,
4206
4207
  metadata
4207
4208
  });
4208
- if (this.#shouldReconnectForStaleActor(group, code, message)) {
4209
+ if (this.#shouldReconnectForStaleActor(group, code)) {
4209
4210
  this.#clearResolvedActorIdentity();
4210
4211
  this.#onOpenPromise?.reject(
4211
4212
  new RivetError(group, code, message, metadata)
@@ -4233,7 +4234,7 @@ var ActorConnRaw = class {
4233
4234
  if (this.#onOpenPromise) {
4234
4235
  this.#onOpenPromise.reject(errorToThrow);
4235
4236
  }
4236
- this.#invalidateActorIfStale(group, code, message);
4237
+ this.#invalidateActorIfStale(group, code);
4237
4238
  for (const [id, inFlight] of this.#actionsInFlight.entries()) {
4238
4239
  inFlight.reject(errorToThrow);
4239
4240
  this.#actionsInFlight.delete(id);
@@ -4936,9 +4937,6 @@ async function resolveGatewayTarget(driver, target) {
4936
4937
  }
4937
4938
 
4938
4939
  // src/client/actor-handle.ts
4939
- var DYNAMIC_LIFECYCLE_RETRY_WINDOW_MS = 100;
4940
- var GET_FOR_KEY_DYNAMIC_QUERY_MAX_ATTEMPTS = 24;
4941
- var GET_OR_CREATE_DYNAMIC_QUERY_MAX_ATTEMPTS = 180;
4942
4940
  var ActorHandleRaw = class {
4943
4941
  #client;
4944
4942
  #driver;
@@ -5001,7 +4999,7 @@ var ActorHandleRaw = class {
5001
4999
  attempt,
5002
5000
  maxAttempts
5003
5001
  )) {
5004
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5002
+ useQueryTarget = true;
5005
5003
  await this.#waitForRetryWindow();
5006
5004
  continue;
5007
5005
  }
@@ -5009,21 +5007,16 @@ var ActorHandleRaw = class {
5009
5007
  group,
5010
5008
  code,
5011
5009
  attempt,
5012
- maxAttempts,
5013
- message
5010
+ maxAttempts
5014
5011
  )) {
5015
5012
  this.#clearResolvedActorId();
5016
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5013
+ useQueryTarget = true;
5017
5014
  await this.#waitForRetryWindow();
5018
5015
  continue;
5019
5016
  }
5020
- const invalidated = this.#invalidateResolvedActorId(
5021
- group,
5022
- code,
5023
- message
5024
- );
5017
+ const invalidated = this.#invalidateResolvedActorId(group, code);
5025
5018
  if (invalidated && attempt < maxAttempts - 1) {
5026
- useQueryTarget = this.#shouldRetryViaQueryTarget() && (code === "stopping" || code.startsWith("destroyed_"));
5019
+ useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
5027
5020
  if (useQueryTarget) {
5028
5021
  await this.#waitForRetryWindow();
5029
5022
  }
@@ -5119,7 +5112,7 @@ var ActorHandleRaw = class {
5119
5112
  attempt,
5120
5113
  maxAttempts
5121
5114
  )) {
5122
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5115
+ useQueryTarget = true;
5123
5116
  await this.#waitForRetryWindow();
5124
5117
  continue;
5125
5118
  }
@@ -5127,11 +5120,10 @@ var ActorHandleRaw = class {
5127
5120
  group,
5128
5121
  code,
5129
5122
  attempt,
5130
- maxAttempts,
5131
- message
5123
+ maxAttempts
5132
5124
  )) {
5133
5125
  this.#clearResolvedActorId();
5134
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5126
+ useQueryTarget = true;
5135
5127
  await this.#waitForRetryWindow();
5136
5128
  continue;
5137
5129
  }
@@ -5143,14 +5135,10 @@ var ActorHandleRaw = class {
5143
5135
  metadata
5144
5136
  );
5145
5137
  }
5146
- const invalidated = this.#invalidateResolvedActorId(
5147
- group,
5148
- code,
5149
- message
5150
- );
5138
+ const invalidated = this.#invalidateResolvedActorId(group, code);
5151
5139
  if (invalidated && attempt < maxAttempts - 1) {
5152
- if (group === "actor" && code === "stopping") {
5153
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5140
+ if (group === "actor" && (code === "starting" || code === "stopping")) {
5141
+ useQueryTarget = true;
5154
5142
  await new Promise((resolve) => setTimeout(resolve, 100));
5155
5143
  }
5156
5144
  continue;
@@ -5172,24 +5160,19 @@ var ActorHandleRaw = class {
5172
5160
  }
5173
5161
  }
5174
5162
  async #waitForRetryWindow() {
5175
- await new Promise(
5176
- (resolve) => setTimeout(resolve, DYNAMIC_LIFECYCLE_RETRY_WINDOW_MS)
5177
- );
5163
+ await new Promise((resolve) => setTimeout(resolve, 100));
5178
5164
  }
5179
5165
  #getDynamicQueryMaxAttempts() {
5180
5166
  if (!isDynamicActorQuery(this.#actorResolutionState)) {
5181
5167
  return 1;
5182
5168
  }
5183
- return "getOrCreateForKey" in this.#actorResolutionState ? GET_OR_CREATE_DYNAMIC_QUERY_MAX_ATTEMPTS : GET_FOR_KEY_DYNAMIC_QUERY_MAX_ATTEMPTS;
5184
- }
5185
- #shouldRetryViaQueryTarget() {
5186
- return isDynamicActorQuery(this.#actorResolutionState);
5169
+ return "getOrCreateForKey" in this.#actorResolutionState ? 60 : 24;
5187
5170
  }
5188
- #shouldRetryDynamicLifecycleError(group, code, attempt, maxAttempts, message) {
5171
+ #shouldRetryDynamicLifecycleError(group, code, attempt, maxAttempts) {
5189
5172
  if (!isDynamicActorQuery(this.#actorResolutionState) || attempt >= maxAttempts - 1 || group !== "actor") {
5190
5173
  return false;
5191
5174
  }
5192
- return code === "not_found" || code === "stopping" || code === "not_configured" && message === "Actor capability 'actor event inbox' is not configured." || code === "destroying" || code.startsWith("destroyed_");
5175
+ return code === "not_found" || code === "starting" || code === "stopping" || code === "destroying" || code.startsWith("destroyed_");
5193
5176
  }
5194
5177
  #clearResolvedActorId() {
5195
5178
  this.#resolvedActorId = void 0;
@@ -5214,8 +5197,8 @@ var ActorHandleRaw = class {
5214
5197
  this.#clearResolvedActorId();
5215
5198
  return true;
5216
5199
  }
5217
- #invalidateResolvedActorId(group, code, message) {
5218
- if (!isDynamicActorQuery(this.#actorResolutionState) || !isStaleResolvedActorError(group, code, message)) {
5200
+ #invalidateResolvedActorId(group, code) {
5201
+ if (!isDynamicActorQuery(this.#actorResolutionState) || !isStaleResolvedActorError(group, code)) {
5219
5202
  return false;
5220
5203
  }
5221
5204
  this.#clearResolvedActorId();
@@ -5321,7 +5304,7 @@ var ActorHandleRaw = class {
5321
5304
  attempt,
5322
5305
  maxAttempts
5323
5306
  )) {
5324
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5307
+ useQueryTarget = true;
5325
5308
  await this.#waitForRetryWindow();
5326
5309
  continue;
5327
5310
  }
@@ -5329,21 +5312,16 @@ var ActorHandleRaw = class {
5329
5312
  group,
5330
5313
  code,
5331
5314
  attempt,
5332
- maxAttempts,
5333
- message
5315
+ maxAttempts
5334
5316
  )) {
5335
5317
  this.#clearResolvedActorId();
5336
- useQueryTarget = this.#shouldRetryViaQueryTarget();
5318
+ useQueryTarget = true;
5337
5319
  await this.#waitForRetryWindow();
5338
5320
  continue;
5339
5321
  }
5340
- const invalidated = this.#invalidateResolvedActorId(
5341
- group,
5342
- code,
5343
- message
5344
- );
5322
+ const invalidated = this.#invalidateResolvedActorId(group, code);
5345
5323
  if (invalidated && attempt < maxAttempts - 1) {
5346
- useQueryTarget = this.#shouldRetryViaQueryTarget() && (code === "stopping" || code.startsWith("destroyed_"));
5324
+ useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
5347
5325
  if (useQueryTarget) {
5348
5326
  await this.#waitForRetryWindow();
5349
5327
  }
@@ -5362,7 +5340,7 @@ var ActorHandleRaw = class {
5362
5340
  if (!error) {
5363
5341
  return null;
5364
5342
  }
5365
- const { group, code, message } = error;
5343
+ const { group, code } = error;
5366
5344
  if (await this.#shouldRetrySchedulingError(
5367
5345
  group,
5368
5346
  code,
@@ -5371,7 +5349,7 @@ var ActorHandleRaw = class {
5371
5349
  maxAttempts
5372
5350
  )) {
5373
5351
  return {
5374
- useQueryTarget: this.#shouldRetryViaQueryTarget(),
5352
+ useQueryTarget: true,
5375
5353
  waitForRetryWindow: true
5376
5354
  };
5377
5355
  }
@@ -5379,22 +5357,17 @@ var ActorHandleRaw = class {
5379
5357
  group,
5380
5358
  code,
5381
5359
  attempt,
5382
- maxAttempts,
5383
- message
5360
+ maxAttempts
5384
5361
  )) {
5385
5362
  this.#clearResolvedActorId();
5386
5363
  return {
5387
- useQueryTarget: this.#shouldRetryViaQueryTarget(),
5364
+ useQueryTarget: true,
5388
5365
  waitForRetryWindow: true
5389
5366
  };
5390
5367
  }
5391
- const invalidated = this.#invalidateResolvedActorId(
5392
- group,
5393
- code,
5394
- message
5395
- );
5368
+ const invalidated = this.#invalidateResolvedActorId(group, code);
5396
5369
  if (invalidated && attempt < maxAttempts - 1) {
5397
- const useQueryTarget = this.#shouldRetryViaQueryTarget() && (code === "stopping" || code.startsWith("destroyed_"));
5370
+ const useQueryTarget = code === "starting" || code === "stopping" || code.startsWith("destroyed_");
5398
5371
  return {
5399
5372
  useQueryTarget,
5400
5373
  waitForRetryWindow: useQueryTarget