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
@@ -230,7 +230,7 @@ function noopNext() {
230
230
  // package.json
231
231
  var package_default = {
232
232
  name: "rivetkit",
233
- version: "3.0.0-preview.4",
233
+ version: "3.0.0-preview.5",
234
234
  description: "Lightweight libraries for building stateful actors on edge platforms",
235
235
  license: "Apache-2.0",
236
236
  keywords: [
@@ -4934,6 +4934,14 @@ function classifyActorError(error) {
4934
4934
  }
4935
4935
  );
4936
4936
  }
4937
+ if (error.group === "ups" && error.code === "consumer_closed" || error.group === "depot" && error.code === "request_deadline_exceeded") {
4938
+ return buildLifecycleBoundaryInfo(
4939
+ "reconnect_only",
4940
+ "actor_error",
4941
+ error.message,
4942
+ { group: error.group, code: error.code }
4943
+ );
4944
+ }
4937
4945
  if (error.group === "guard" && isRetryableGuardGatewayHttpError(error.code)) {
4938
4946
  return buildLifecycleBoundaryInfo(
4939
4947
  "request_retry",
@@ -5254,6 +5262,8 @@ var ActorConnRaw = class {
5254
5262
  /* Will be aborted on dispose. */
5255
5263
  #abortController = new AbortController();
5256
5264
  #connStatus = "idle";
5265
+ /** The opening failure that stopped retries. Later actions must fail instead of queueing. */
5266
+ #connectionOpenError;
5257
5267
  #actorId;
5258
5268
  #connId;
5259
5269
  #messageQueue = [];
@@ -5372,6 +5382,8 @@ var ActorConnRaw = class {
5372
5382
  `Invalid action call: expected an options object { name, args }, got ${typeof opts}. Use conn.actionName(...args) for the shorthand API.`
5373
5383
  );
5374
5384
  }
5385
+ if (this.#disposed) throw new ActorConnDisposed();
5386
+ if (this.#connectionOpenError) throw this.#connectionOpenError;
5375
5387
  logger2().debug({ msg: "action", name: opts.name, args: opts.args });
5376
5388
  const actionId = this.#actionIdCounter;
5377
5389
  this.#actionIdCounter += 1;
@@ -5459,6 +5471,7 @@ var ActorConnRaw = class {
5459
5471
  }
5460
5472
  }
5461
5473
  #connectWithRetry() {
5474
+ this.#connectionOpenError = void 0;
5462
5475
  this.#setConnStatus("connecting");
5463
5476
  pRetry2(this.#connectAndWait.bind(this), {
5464
5477
  forever: true,
@@ -5501,6 +5514,9 @@ var ActorConnRaw = class {
5501
5514
  await this.#connectWebSocket();
5502
5515
  await this.#waitForOpen(this.#onOpenPromise.promise);
5503
5516
  } catch (error) {
5517
+ this.#abandonCurrentSocket(
5518
+ isConnectionOpenTimeout(error) ? "Connect timeout" : "Connection opening failed"
5519
+ );
5504
5520
  if (this.#shouldRetryConnectionOpenError(error)) {
5505
5521
  throw error;
5506
5522
  }
@@ -5510,7 +5526,7 @@ var ActorConnRaw = class {
5510
5526
  `Failed to open connection: ${stringifyError(error)}`,
5511
5527
  { error: stringifyError(error) }
5512
5528
  );
5513
- this.#clearQueuedMessages();
5529
+ this.#connectionOpenError = actorError;
5514
5530
  this.#rejectPendingPromises(actorError, false);
5515
5531
  this.#dispatchActorError(actorError);
5516
5532
  this.#setConnStatus("idle");
@@ -5542,28 +5558,23 @@ var ActorConnRaw = class {
5542
5558
  });
5543
5559
  try {
5544
5560
  await Promise.race([open, timedOut]);
5545
- } catch (error) {
5546
- if (isConnectionOpenTimeout(error)) {
5547
- this.#abandonCurrentSocket();
5548
- }
5549
- throw error;
5550
5561
  } finally {
5551
5562
  clearTimeout(timer);
5552
5563
  }
5553
5564
  }
5554
- #abandonCurrentSocket() {
5565
+ #abandonCurrentSocket(reason) {
5555
5566
  const ws = this.#websocket;
5556
5567
  if (!ws) return;
5557
5568
  this.#websocket = void 0;
5558
5569
  this.#abandonedSockets.add(ws);
5559
- logger2().warn({
5560
- msg: "connection did not open in time, retrying",
5570
+ logger2().debug({
5571
+ msg: "closing failed connection attempt",
5561
5572
  connId: this.#connId,
5562
5573
  readyState: ws.readyState,
5563
- timeoutMs: CONNECT_TIMEOUT_MS
5574
+ reason
5564
5575
  });
5565
5576
  try {
5566
- ws.close(1e3, "Connect timeout");
5577
+ ws.close(1e3, reason);
5567
5578
  } catch (err) {
5568
5579
  logger2().debug({
5569
5580
  msg: "failed to close abandoned websocket",
@@ -5827,14 +5838,8 @@ var ActorConnRaw = class {
5827
5838
  errorToThrow = schedulingError;
5828
5839
  }
5829
5840
  }
5830
- if (this.#onOpenPromise) {
5831
- this.#onOpenPromise.reject(errorToThrow);
5832
- }
5833
5841
  this.#invalidateActorIfStale(group, code);
5834
- for (const [id, inFlight] of this.#actionsInFlight.entries()) {
5835
- inFlight.reject(errorToThrow);
5836
- this.#actionsInFlight.delete(id);
5837
- }
5842
+ this.#rejectPendingPromises(errorToThrow, false);
5838
5843
  this.#dispatchActorError(errorToThrow);
5839
5844
  }
5840
5845
  } else if (response.body.tag === "ActionResponse") {
@@ -5963,6 +5968,7 @@ var ActorConnRaw = class {
5963
5968
  }
5964
5969
  }
5965
5970
  #rejectPendingPromises(error, suppressUnhandled) {
5971
+ this.#clearQueuedMessages();
5966
5972
  if (this.#onOpenPromise) {
5967
5973
  if (suppressUnhandled) {
5968
5974
  this.#onOpenPromise.promise.catch(() => {