rivetkit 3.0.0-preview.4 → 3.0.0-preview.5

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 (64) hide show
  1. package/dist/browser/client.js +25 -19
  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-OR3LWJGW.js → chunk-AW7C2XT5.js} +2 -2
  6. package/dist/tsup/{chunk-DCUTYXIX.js → chunk-BAXQGOBL.js} +2 -2
  7. package/dist/tsup/{chunk-SR362FVR.cjs → chunk-CFGRIV62.cjs} +2 -2
  8. package/dist/tsup/{chunk-SR362FVR.cjs.map → chunk-CFGRIV62.cjs.map} +1 -1
  9. package/dist/tsup/{chunk-S5QNPQ6K.cjs → chunk-CLY73DEM.cjs} +3 -3
  10. package/dist/tsup/{chunk-S5QNPQ6K.cjs.map → chunk-CLY73DEM.cjs.map} +1 -1
  11. package/dist/tsup/{chunk-LTMP7OMQ.cjs → chunk-EON5X6B7.cjs} +3 -3
  12. package/dist/tsup/{chunk-LTMP7OMQ.cjs.map → chunk-EON5X6B7.cjs.map} +1 -1
  13. package/dist/tsup/{chunk-C45DIKGB.js → chunk-EOUH7MP7.js} +30 -24
  14. package/dist/tsup/chunk-EOUH7MP7.js.map +1 -0
  15. package/dist/tsup/{chunk-5IZ36V3N.cjs → chunk-GJUWI47D.cjs} +167 -161
  16. package/dist/tsup/chunk-GJUWI47D.cjs.map +1 -0
  17. package/dist/tsup/{chunk-KSQ3VVZX.cjs → chunk-KEHBPXZE.cjs} +3 -3
  18. package/dist/tsup/{chunk-KSQ3VVZX.cjs.map → chunk-KEHBPXZE.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-ZWBTTPP3.js → chunk-KJM23DKG.js} +2 -2
  20. package/dist/tsup/{chunk-MAUVZIXL.js → chunk-KKSIGBUN.js} +2 -2
  21. package/dist/tsup/{chunk-MAUVZIXL.js.map → chunk-KKSIGBUN.js.map} +1 -1
  22. package/dist/tsup/{chunk-WE5DMJFV.cjs → chunk-MVDTFTCY.cjs} +7 -7
  23. package/dist/tsup/{chunk-WE5DMJFV.cjs.map → chunk-MVDTFTCY.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-SLIGV2T4.cjs → chunk-PHFXQQGE.cjs} +4 -4
  25. package/dist/tsup/{chunk-SLIGV2T4.cjs.map → chunk-PHFXQQGE.cjs.map} +1 -1
  26. package/dist/tsup/{chunk-IPDSE33U.js → chunk-SJUGJ5DT.js} +2 -2
  27. package/dist/tsup/{chunk-KM34T23X.js → chunk-W4CGRSYM.js} +3 -3
  28. package/dist/tsup/{chunk-WQFXPN6S.js → chunk-W5DDGJBO.js} +4 -4
  29. package/dist/tsup/{chunk-U2QBZJTL.cjs → chunk-ZOFNA4SR.cjs} +10 -10
  30. package/dist/tsup/{chunk-U2QBZJTL.cjs.map → chunk-ZOFNA4SR.cjs.map} +1 -1
  31. package/dist/tsup/client/mod.cjs +5 -5
  32. package/dist/tsup/client/mod.js +4 -4
  33. package/dist/tsup/common/log.cjs +2 -2
  34. package/dist/tsup/common/log.js +1 -1
  35. package/dist/tsup/common/websocket.cjs +3 -3
  36. package/dist/tsup/common/websocket.js +2 -2
  37. package/dist/tsup/db/drizzle.cjs +2 -2
  38. package/dist/tsup/db/drizzle.js +1 -1
  39. package/dist/tsup/db/mod.cjs +3 -3
  40. package/dist/tsup/db/mod.js +2 -2
  41. package/dist/tsup/inspector/mod.cjs +5 -5
  42. package/dist/tsup/inspector/mod.js +4 -4
  43. package/dist/tsup/inspector/workflow.cjs +4 -4
  44. package/dist/tsup/inspector/workflow.js +3 -3
  45. package/dist/tsup/mod.cjs +86 -86
  46. package/dist/tsup/mod.cjs.map +1 -1
  47. package/dist/tsup/mod.js +5 -5
  48. package/dist/tsup/test/mod.cjs +6 -6
  49. package/dist/tsup/test/mod.js +4 -4
  50. package/dist/tsup/utils.cjs +2 -2
  51. package/dist/tsup/utils.js +1 -1
  52. package/dist/tsup/workflow/mod.cjs +7 -7
  53. package/dist/tsup/workflow/mod.js +4 -4
  54. package/package.json +9 -9
  55. package/src/client/actor-conn.ts +21 -24
  56. package/src/client/lifecycle-errors.ts +13 -0
  57. package/dist/tsup/chunk-5IZ36V3N.cjs.map +0 -1
  58. package/dist/tsup/chunk-C45DIKGB.js.map +0 -1
  59. /package/dist/tsup/{chunk-OR3LWJGW.js.map → chunk-AW7C2XT5.js.map} +0 -0
  60. /package/dist/tsup/{chunk-DCUTYXIX.js.map → chunk-BAXQGOBL.js.map} +0 -0
  61. /package/dist/tsup/{chunk-ZWBTTPP3.js.map → chunk-KJM23DKG.js.map} +0 -0
  62. /package/dist/tsup/{chunk-IPDSE33U.js.map → chunk-SJUGJ5DT.js.map} +0 -0
  63. /package/dist/tsup/{chunk-KM34T23X.js.map → chunk-W4CGRSYM.js.map} +0 -0
  64. /package/dist/tsup/{chunk-WQFXPN6S.js.map → chunk-W5DDGJBO.js.map} +0 -0
@@ -3,13 +3,13 @@ import {
3
3
  deserializeActorKey,
4
4
  serializeActorKey
5
5
  } from "./chunk-A2CF6PFH.js";
6
- import {
7
- importWebSocket,
8
- logger
9
- } from "./chunk-IPDSE33U.js";
10
6
  import {
11
7
  AsyncMutex
12
8
  } from "./chunk-JTHHCZCZ.js";
9
+ import {
10
+ importWebSocket,
11
+ logger
12
+ } from "./chunk-SJUGJ5DT.js";
13
13
  import {
14
14
  EncodingSchema,
15
15
  assertUnreachable,
@@ -36,7 +36,7 @@ import {
36
36
  serializeWithEncoding,
37
37
  stringifyError,
38
38
  uint8ArrayToBase64
39
- } from "./chunk-MAUVZIXL.js";
39
+ } from "./chunk-KKSIGBUN.js";
40
40
  import {
41
41
  INTERNAL_ERROR_CODE,
42
42
  RivetError,
@@ -2266,6 +2266,14 @@ function classifyActorError(error) {
2266
2266
  }
2267
2267
  );
2268
2268
  }
2269
+ if (error.group === "ups" && error.code === "consumer_closed" || error.group === "depot" && error.code === "request_deadline_exceeded") {
2270
+ return buildLifecycleBoundaryInfo(
2271
+ "reconnect_only",
2272
+ "actor_error",
2273
+ error.message,
2274
+ { group: error.group, code: error.code }
2275
+ );
2276
+ }
2269
2277
  if (error.group === "guard" && isRetryableGuardGatewayHttpError(error.code)) {
2270
2278
  return buildLifecycleBoundaryInfo(
2271
2279
  "request_retry",
@@ -4020,6 +4028,8 @@ var ActorConnRaw = class {
4020
4028
  /* Will be aborted on dispose. */
4021
4029
  #abortController = new AbortController();
4022
4030
  #connStatus = "idle";
4031
+ /** The opening failure that stopped retries. Later actions must fail instead of queueing. */
4032
+ #connectionOpenError;
4023
4033
  #actorId;
4024
4034
  #connId;
4025
4035
  #messageQueue = [];
@@ -4141,6 +4151,8 @@ var ActorConnRaw = class {
4141
4151
  `Invalid action call: expected an options object { name, args }, got ${typeof opts}. Use conn.actionName(...args) for the shorthand API.`
4142
4152
  );
4143
4153
  }
4154
+ if (this.#disposed) throw new ActorConnDisposed();
4155
+ if (this.#connectionOpenError) throw this.#connectionOpenError;
4144
4156
  logger().debug({ msg: "action", name: opts.name, args: opts.args });
4145
4157
  const actionId = this.#actionIdCounter;
4146
4158
  this.#actionIdCounter += 1;
@@ -4228,6 +4240,7 @@ var ActorConnRaw = class {
4228
4240
  }
4229
4241
  }
4230
4242
  #connectWithRetry() {
4243
+ this.#connectionOpenError = void 0;
4231
4244
  this.#setConnStatus("connecting");
4232
4245
  pRetry(this.#connectAndWait.bind(this), {
4233
4246
  forever: true,
@@ -4270,6 +4283,9 @@ var ActorConnRaw = class {
4270
4283
  await this.#connectWebSocket();
4271
4284
  await this.#waitForOpen(this.#onOpenPromise.promise);
4272
4285
  } catch (error) {
4286
+ this.#abandonCurrentSocket(
4287
+ isConnectionOpenTimeout(error) ? "Connect timeout" : "Connection opening failed"
4288
+ );
4273
4289
  if (this.#shouldRetryConnectionOpenError(error)) {
4274
4290
  throw error;
4275
4291
  }
@@ -4279,7 +4295,7 @@ var ActorConnRaw = class {
4279
4295
  `Failed to open connection: ${stringifyError(error)}`,
4280
4296
  { error: stringifyError(error) }
4281
4297
  );
4282
- this.#clearQueuedMessages();
4298
+ this.#connectionOpenError = actorError;
4283
4299
  this.#rejectPendingPromises(actorError, false);
4284
4300
  this.#dispatchActorError(actorError);
4285
4301
  this.#setConnStatus("idle");
@@ -4311,28 +4327,23 @@ var ActorConnRaw = class {
4311
4327
  });
4312
4328
  try {
4313
4329
  await Promise.race([open, timedOut]);
4314
- } catch (error) {
4315
- if (isConnectionOpenTimeout(error)) {
4316
- this.#abandonCurrentSocket();
4317
- }
4318
- throw error;
4319
4330
  } finally {
4320
4331
  clearTimeout(timer);
4321
4332
  }
4322
4333
  }
4323
- #abandonCurrentSocket() {
4334
+ #abandonCurrentSocket(reason) {
4324
4335
  const ws = this.#websocket;
4325
4336
  if (!ws) return;
4326
4337
  this.#websocket = void 0;
4327
4338
  this.#abandonedSockets.add(ws);
4328
- logger().warn({
4329
- msg: "connection did not open in time, retrying",
4339
+ logger().debug({
4340
+ msg: "closing failed connection attempt",
4330
4341
  connId: this.#connId,
4331
4342
  readyState: ws.readyState,
4332
- timeoutMs: CONNECT_TIMEOUT_MS
4343
+ reason
4333
4344
  });
4334
4345
  try {
4335
- ws.close(1e3, "Connect timeout");
4346
+ ws.close(1e3, reason);
4336
4347
  } catch (err) {
4337
4348
  logger().debug({
4338
4349
  msg: "failed to close abandoned websocket",
@@ -4597,14 +4608,8 @@ var ActorConnRaw = class {
4597
4608
  errorToThrow = schedulingError;
4598
4609
  }
4599
4610
  }
4600
- if (this.#onOpenPromise) {
4601
- this.#onOpenPromise.reject(errorToThrow);
4602
- }
4603
4611
  this.#invalidateActorIfStale(group, code);
4604
- for (const [id, inFlight] of this.#actionsInFlight.entries()) {
4605
- inFlight.reject(errorToThrow);
4606
- this.#actionsInFlight.delete(id);
4607
- }
4612
+ this.#rejectPendingPromises(errorToThrow, false);
4608
4613
  this.#dispatchActorError(errorToThrow);
4609
4614
  }
4610
4615
  } else if (response.body.tag === "ActionResponse") {
@@ -4735,6 +4740,7 @@ var ActorConnRaw = class {
4735
4740
  }
4736
4741
  }
4737
4742
  #rejectPendingPromises(error, suppressUnhandled) {
4743
+ this.#clearQueuedMessages();
4738
4744
  if (this.#onOpenPromise) {
4739
4745
  if (suppressUnhandled) {
4740
4746
  this.#onOpenPromise.promise.catch(() => {
@@ -6544,4 +6550,4 @@ export {
6544
6550
  updateRunnerConfig,
6545
6551
  RemoteEngineControlClient
6546
6552
  };
6547
- //# sourceMappingURL=chunk-C45DIKGB.js.map
6553
+ //# sourceMappingURL=chunk-EOUH7MP7.js.map