rivetkit 3.0.0-preview.3 → 3.0.0-preview.4

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 (67) hide show
  1. package/dist/browser/client.js +25 -10
  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-BCX5V7NI.cjs → chunk-5IZ36V3N.cjs} +167 -152
  6. package/dist/tsup/chunk-5IZ36V3N.cjs.map +1 -0
  7. package/dist/tsup/{chunk-2VXPVVNW.js → chunk-C45DIKGB.js} +27 -12
  8. package/dist/tsup/chunk-C45DIKGB.js.map +1 -0
  9. package/dist/tsup/{chunk-JWI6YJEA.js → chunk-DCUTYXIX.js} +2 -2
  10. package/dist/tsup/{chunk-A447S5YG.js → chunk-IPDSE33U.js} +2 -2
  11. package/dist/tsup/{chunk-AGQNNAZ2.js → chunk-KM34T23X.js} +3 -3
  12. package/dist/tsup/{chunk-PJ4PORWE.cjs → chunk-KSQ3VVZX.cjs} +3 -3
  13. package/dist/tsup/{chunk-PJ4PORWE.cjs.map → chunk-KSQ3VVZX.cjs.map} +1 -1
  14. package/dist/tsup/{chunk-KMYBA4P5.cjs → chunk-LTMP7OMQ.cjs} +3 -3
  15. package/dist/tsup/{chunk-KMYBA4P5.cjs.map → chunk-LTMP7OMQ.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-JXO5QVDX.js → chunk-MAUVZIXL.js} +2 -2
  17. package/dist/tsup/{chunk-JXO5QVDX.js.map → chunk-MAUVZIXL.js.map} +1 -1
  18. package/dist/tsup/{chunk-KCWRKXTY.js → chunk-OR3LWJGW.js} +2 -2
  19. package/dist/tsup/{chunk-7KES6QNE.cjs → chunk-S5QNPQ6K.cjs} +3 -3
  20. package/dist/tsup/{chunk-7KES6QNE.cjs.map → chunk-S5QNPQ6K.cjs.map} +1 -1
  21. package/dist/tsup/{chunk-B6U5V6WE.cjs → chunk-SLIGV2T4.cjs} +4 -4
  22. package/dist/tsup/{chunk-B6U5V6WE.cjs.map → chunk-SLIGV2T4.cjs.map} +1 -1
  23. package/dist/tsup/{chunk-4WDX5ZI7.cjs → chunk-SR362FVR.cjs} +2 -2
  24. package/dist/tsup/{chunk-4WDX5ZI7.cjs.map → chunk-SR362FVR.cjs.map} +1 -1
  25. package/dist/tsup/{chunk-7Y4GHUAT.cjs → chunk-U2QBZJTL.cjs} +10 -10
  26. package/dist/tsup/{chunk-7Y4GHUAT.cjs.map → chunk-U2QBZJTL.cjs.map} +1 -1
  27. package/dist/tsup/{chunk-HRBZ4VW5.cjs → chunk-WE5DMJFV.cjs} +7 -7
  28. package/dist/tsup/{chunk-HRBZ4VW5.cjs.map → chunk-WE5DMJFV.cjs.map} +1 -1
  29. package/dist/tsup/{chunk-IJGFSNGA.js → chunk-WQFXPN6S.js} +4 -4
  30. package/dist/tsup/{chunk-HDQQVBOG.js → chunk-ZWBTTPP3.js} +2 -2
  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 +94 -90
  46. package/dist/tsup/mod.cjs.map +1 -1
  47. package/dist/tsup/mod.js +15 -11
  48. package/dist/tsup/mod.js.map +1 -1
  49. package/dist/tsup/test/mod.cjs +6 -6
  50. package/dist/tsup/test/mod.js +4 -4
  51. package/dist/tsup/utils.cjs +2 -2
  52. package/dist/tsup/utils.js +1 -1
  53. package/dist/tsup/workflow/mod.cjs +7 -7
  54. package/dist/tsup/workflow/mod.cjs.map +1 -1
  55. package/dist/tsup/workflow/mod.js +4 -4
  56. package/package.json +9 -9
  57. package/src/client/actor-conn.ts +38 -9
  58. package/src/registry/config/index.ts +2 -1
  59. package/src/registry/index.ts +16 -3
  60. package/dist/tsup/chunk-2VXPVVNW.js.map +0 -1
  61. package/dist/tsup/chunk-BCX5V7NI.cjs.map +0 -1
  62. /package/dist/tsup/{chunk-JWI6YJEA.js.map → chunk-DCUTYXIX.js.map} +0 -0
  63. /package/dist/tsup/{chunk-A447S5YG.js.map → chunk-IPDSE33U.js.map} +0 -0
  64. /package/dist/tsup/{chunk-AGQNNAZ2.js.map → chunk-KM34T23X.js.map} +0 -0
  65. /package/dist/tsup/{chunk-KCWRKXTY.js.map → chunk-OR3LWJGW.js.map} +0 -0
  66. /package/dist/tsup/{chunk-IJGFSNGA.js.map → chunk-WQFXPN6S.js.map} +0 -0
  67. /package/dist/tsup/{chunk-HDQQVBOG.js.map → chunk-ZWBTTPP3.js.map} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  importWebSocket,
8
8
  logger
9
- } from "./chunk-A447S5YG.js";
9
+ } from "./chunk-IPDSE33U.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-JXO5QVDX.js";
39
+ } from "./chunk-MAUVZIXL.js";
40
40
  import {
41
41
  INTERNAL_ERROR_CODE,
42
42
  RivetError,
@@ -4347,6 +4347,9 @@ var ActorConnRaw = class {
4347
4347
  if (isConnectionOpenTimeout(error)) {
4348
4348
  return true;
4349
4349
  }
4350
+ if (error instanceof RivetError && error.group === "client" && error.code === "connection_open_interrupted") {
4351
+ return true;
4352
+ }
4350
4353
  if (error instanceof RivetError && isInvalidToken(error.group, error.code) && this.#driver.refreshAuthToken && this.#authRetryAvailable) {
4351
4354
  this.#authRetryAvailable = false;
4352
4355
  return true;
@@ -4406,16 +4409,18 @@ var ActorConnRaw = class {
4406
4409
  });
4407
4410
  this.#websocket = ws;
4408
4411
  ws.addEventListener("open", () => {
4409
- if (this.#abandonedSockets.has(ws)) return;
4412
+ if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
4413
+ return;
4410
4414
  logger().debug({
4411
4415
  msg: "client websocket open",
4412
4416
  connId: this.#connId
4413
4417
  });
4414
4418
  });
4415
4419
  ws.addEventListener("message", async (ev) => {
4416
- if (this.#abandonedSockets.has(ws)) return;
4420
+ if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
4421
+ return;
4417
4422
  try {
4418
- await this.#handleOnMessage(ev.data);
4423
+ await this.#handleOnMessage(ev.data, ws);
4419
4424
  } catch (err) {
4420
4425
  logger().error({
4421
4426
  msg: "error in websocket message handler",
@@ -4424,7 +4429,8 @@ var ActorConnRaw = class {
4424
4429
  }
4425
4430
  });
4426
4431
  ws.addEventListener("close", async (ev) => {
4427
- if (this.#abandonedSockets.has(ws)) return;
4432
+ if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
4433
+ return;
4428
4434
  try {
4429
4435
  await this.#handleOnClose(ev);
4430
4436
  } catch (err) {
@@ -4435,7 +4441,8 @@ var ActorConnRaw = class {
4435
4441
  }
4436
4442
  });
4437
4443
  ws.addEventListener("error", () => {
4438
- if (this.#abandonedSockets.has(ws)) return;
4444
+ if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
4445
+ return;
4439
4446
  try {
4440
4447
  this.#handleOnError();
4441
4448
  } catch (err) {
@@ -4501,7 +4508,7 @@ var ActorConnRaw = class {
4501
4508
  });
4502
4509
  }
4503
4510
  /** Called by the onmessage event from drivers. */
4504
- async #handleOnMessage(data) {
4511
+ async #handleOnMessage(data, socket) {
4505
4512
  var _a;
4506
4513
  logger().trace({
4507
4514
  msg: "received message",
@@ -4510,6 +4517,8 @@ var ActorConnRaw = class {
4510
4517
  isArrayBuffer: data instanceof ArrayBuffer
4511
4518
  });
4512
4519
  const response = await this.#parseMessage(data);
4520
+ if (this.#websocket !== socket || this.#abandonedSockets.has(socket))
4521
+ return;
4513
4522
  logger().trace(
4514
4523
  getLogMessage() ? {
4515
4524
  msg: "parsed message",
@@ -4581,6 +4590,9 @@ var ActorConnRaw = class {
4581
4590
  this.#actorResolutionState,
4582
4591
  this.#driver
4583
4592
  );
4593
+ if (this.#websocket !== socket || this.#abandonedSockets.has(socket)) {
4594
+ return;
4595
+ }
4584
4596
  if (schedulingError) {
4585
4597
  errorToThrow = schedulingError;
4586
4598
  }
@@ -4702,9 +4714,12 @@ var ActorConnRaw = class {
4702
4714
  }
4703
4715
  this.#invalidateActorIfStale(group, code);
4704
4716
  } else {
4705
- error = new Error(
4706
- `${wasClean ? "Connection closed" : "Connection lost"} (code: ${closeEvent.code}, reason: ${reason})`
4707
- );
4717
+ const message = `${wasClean ? "Connection closed" : "Connection lost"} (code: ${closeEvent.code}, reason: ${reason})`;
4718
+ error = !wasConnected && closeEvent.code === 1006 ? new RivetError(
4719
+ "client",
4720
+ "connection_open_interrupted",
4721
+ message
4722
+ ) : new Error(message);
4708
4723
  }
4709
4724
  this.#rejectPendingPromises(error, false);
4710
4725
  if (error instanceof RivetError) {
@@ -6529,4 +6544,4 @@ export {
6529
6544
  updateRunnerConfig,
6530
6545
  RemoteEngineControlClient
6531
6546
  };
6532
- //# sourceMappingURL=chunk-2VXPVVNW.js.map
6547
+ //# sourceMappingURL=chunk-C45DIKGB.js.map