rivetkit 2.0.25-rc.1 → 2.0.25

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 (91) hide show
  1. package/dist/tsup/actor/errors.cjs +2 -6
  2. package/dist/tsup/actor/errors.cjs.map +1 -1
  3. package/dist/tsup/actor/errors.d.cts +2 -10
  4. package/dist/tsup/actor/errors.d.ts +2 -10
  5. package/dist/tsup/actor/errors.js +3 -7
  6. package/dist/tsup/{chunk-YHWIOWVA.cjs → chunk-2G2VNBLZ.cjs} +8 -8
  7. package/dist/tsup/{chunk-YHWIOWVA.cjs.map → chunk-2G2VNBLZ.cjs.map} +1 -1
  8. package/dist/tsup/{chunk-WQU4M4ZC.cjs → chunk-4JW72PP6.cjs} +10 -10
  9. package/dist/tsup/{chunk-WQU4M4ZC.cjs.map → chunk-4JW72PP6.cjs.map} +1 -1
  10. package/dist/tsup/{chunk-H7GV5DIW.cjs → chunk-5WBIOFZH.cjs} +9 -9
  11. package/dist/tsup/chunk-5WBIOFZH.cjs.map +1 -0
  12. package/dist/tsup/{chunk-IDJK7ILQ.js → chunk-7MNVTI4Q.js} +2 -2
  13. package/dist/tsup/{chunk-AZATXPR4.cjs → chunk-AGFBQ4NP.cjs} +3 -3
  14. package/dist/tsup/{chunk-AZATXPR4.cjs.map → chunk-AGFBQ4NP.cjs.map} +1 -1
  15. package/dist/tsup/{chunk-3FG5OJ3G.cjs → chunk-BTGTFZMA.cjs} +3 -3
  16. package/dist/tsup/{chunk-3FG5OJ3G.cjs.map → chunk-BTGTFZMA.cjs.map} +1 -1
  17. package/dist/tsup/{chunk-EDGN4OC7.js → chunk-CZOVXLGY.js} +2 -2
  18. package/dist/tsup/{chunk-ILFXA4AL.cjs → chunk-DXDH4HIP.cjs} +185 -181
  19. package/dist/tsup/chunk-DXDH4HIP.cjs.map +1 -0
  20. package/dist/tsup/{chunk-6JN6W6G3.js → chunk-EDCGRWSB.js} +3 -3
  21. package/dist/tsup/{chunk-YVL6IRUM.js → chunk-FXGOD53M.js} +3 -3
  22. package/dist/tsup/{chunk-E63WZNMR.cjs → chunk-HBSVF6Y2.cjs} +6 -6
  23. package/dist/tsup/{chunk-E63WZNMR.cjs.map → chunk-HBSVF6Y2.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-NWBKMCWC.js → chunk-HK2X2UOP.js} +4 -4
  25. package/dist/tsup/chunk-HK2X2UOP.js.map +1 -0
  26. package/dist/tsup/{chunk-W6RDS6NW.js → chunk-LQOCWGP6.js} +3 -32
  27. package/dist/tsup/chunk-LQOCWGP6.js.map +1 -0
  28. package/dist/tsup/{chunk-FLOQ3UWM.js → chunk-Q4FKZ7DP.js} +14 -10
  29. package/dist/tsup/chunk-Q4FKZ7DP.js.map +1 -0
  30. package/dist/tsup/{chunk-QIHBDXTO.js → chunk-QGOLWFPJ.js} +2 -2
  31. package/dist/tsup/{chunk-7IBNNGQ2.js → chunk-RDUHRPFX.js} +3 -3
  32. package/dist/tsup/{chunk-BBVFDEYD.js → chunk-RI4XXOSM.js} +6 -6
  33. package/dist/tsup/{chunk-B7MENRD5.cjs → chunk-RI7O6GWM.cjs} +224 -224
  34. package/dist/tsup/chunk-RI7O6GWM.cjs.map +1 -0
  35. package/dist/tsup/{chunk-MV6M3FDL.cjs → chunk-RPI5AI2C.cjs} +17 -17
  36. package/dist/tsup/{chunk-MV6M3FDL.cjs.map → chunk-RPI5AI2C.cjs.map} +1 -1
  37. package/dist/tsup/{chunk-HZYZ7JSF.js → chunk-UTU3KZQ7.js} +11 -11
  38. package/dist/tsup/chunk-UTU3KZQ7.js.map +1 -0
  39. package/dist/tsup/{chunk-XKZA47XS.cjs → chunk-UXV42P7I.cjs} +14 -14
  40. package/dist/tsup/{chunk-XKZA47XS.cjs.map → chunk-UXV42P7I.cjs.map} +1 -1
  41. package/dist/tsup/{chunk-D6762AOA.cjs → chunk-XJMYGATE.cjs} +3 -32
  42. package/dist/tsup/chunk-XJMYGATE.cjs.map +1 -0
  43. package/dist/tsup/client/mod.cjs +9 -9
  44. package/dist/tsup/client/mod.js +8 -8
  45. package/dist/tsup/common/log.cjs +3 -3
  46. package/dist/tsup/common/log.js +2 -2
  47. package/dist/tsup/common/websocket.cjs +4 -4
  48. package/dist/tsup/common/websocket.js +3 -3
  49. package/dist/tsup/driver-helpers/mod.cjs +5 -5
  50. package/dist/tsup/driver-helpers/mod.js +4 -4
  51. package/dist/tsup/driver-test-suite/mod.cjs +228 -226
  52. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  53. package/dist/tsup/driver-test-suite/mod.js +456 -454
  54. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  55. package/dist/tsup/inspector/mod.cjs +6 -6
  56. package/dist/tsup/inspector/mod.js +5 -5
  57. package/dist/tsup/mod.cjs +10 -10
  58. package/dist/tsup/mod.js +9 -9
  59. package/dist/tsup/test/mod.cjs +11 -11
  60. package/dist/tsup/test/mod.js +10 -10
  61. package/dist/tsup/utils.cjs +3 -3
  62. package/dist/tsup/utils.js +2 -2
  63. package/package.json +3 -3
  64. package/src/actor/conn/drivers/raw-websocket.ts +1 -1
  65. package/src/actor/conn/drivers/websocket.ts +1 -1
  66. package/src/actor/conn/state-manager.ts +1 -1
  67. package/src/actor/errors.ts +1 -32
  68. package/src/actor/instance/mod.ts +1 -1
  69. package/src/actor/instance/state-manager.ts +1 -1
  70. package/src/driver-test-suite/mod.ts +1 -1
  71. package/src/driver-test-suite/test-inline-client-driver.ts +3 -1
  72. package/src/driver-test-suite/tests/actor-conn-hibernation.ts +3 -1
  73. package/src/driver-test-suite/utils.ts +1 -1
  74. package/src/manager/gateway.ts +3 -1
  75. package/src/manager/router.ts +3 -1
  76. package/src/utils/node.ts +0 -8
  77. package/dist/tsup/chunk-B7MENRD5.cjs.map +0 -1
  78. package/dist/tsup/chunk-D6762AOA.cjs.map +0 -1
  79. package/dist/tsup/chunk-FLOQ3UWM.js.map +0 -1
  80. package/dist/tsup/chunk-H7GV5DIW.cjs.map +0 -1
  81. package/dist/tsup/chunk-HZYZ7JSF.js.map +0 -1
  82. package/dist/tsup/chunk-ILFXA4AL.cjs.map +0 -1
  83. package/dist/tsup/chunk-NWBKMCWC.js.map +0 -1
  84. package/dist/tsup/chunk-W6RDS6NW.js.map +0 -1
  85. /package/dist/tsup/{chunk-IDJK7ILQ.js.map → chunk-7MNVTI4Q.js.map} +0 -0
  86. /package/dist/tsup/{chunk-EDGN4OC7.js.map → chunk-CZOVXLGY.js.map} +0 -0
  87. /package/dist/tsup/{chunk-6JN6W6G3.js.map → chunk-EDCGRWSB.js.map} +0 -0
  88. /package/dist/tsup/{chunk-YVL6IRUM.js.map → chunk-FXGOD53M.js.map} +0 -0
  89. /package/dist/tsup/{chunk-QIHBDXTO.js.map → chunk-QGOLWFPJ.js.map} +0 -0
  90. /package/dist/tsup/{chunk-7IBNNGQ2.js.map → chunk-RDUHRPFX.js.map} +0 -0
  91. /package/dist/tsup/{chunk-BBVFDEYD.js.map → chunk-RI4XXOSM.js.map} +0 -0
@@ -1,30 +1,30 @@
1
1
  import {
2
2
  getPort
3
- } from "../chunk-BBVFDEYD.js";
3
+ } from "../chunk-RI4XXOSM.js";
4
4
  import {
5
5
  actor,
6
6
  createManagerRouter
7
- } from "../chunk-FLOQ3UWM.js";
7
+ } from "../chunk-Q4FKZ7DP.js";
8
8
  import {
9
9
  configureInspectorAccessToken,
10
10
  createActorInspectorClient,
11
11
  createManagerInspectorClient
12
- } from "../chunk-IDJK7ILQ.js";
12
+ } from "../chunk-7MNVTI4Q.js";
13
13
  import {
14
14
  createClient
15
- } from "../chunk-YVL6IRUM.js";
15
+ } from "../chunk-FXGOD53M.js";
16
16
  import {
17
17
  ActorError,
18
18
  createClientWithDriver
19
- } from "../chunk-HZYZ7JSF.js";
20
- import "../chunk-EDGN4OC7.js";
19
+ } from "../chunk-UTU3KZQ7.js";
20
+ import "../chunk-CZOVXLGY.js";
21
21
  import {
22
22
  importWebSocket
23
- } from "../chunk-QIHBDXTO.js";
23
+ } from "../chunk-QGOLWFPJ.js";
24
24
  import {
25
25
  ClientConfigSchema,
26
26
  RunnerConfigSchema
27
- } from "../chunk-7IBNNGQ2.js";
27
+ } from "../chunk-RDUHRPFX.js";
28
28
  import {
29
29
  HEADER_ACTOR_ID,
30
30
  HEADER_ACTOR_QUERY,
@@ -35,15 +35,15 @@ import {
35
35
  WS_PROTOCOL_TARGET,
36
36
  WS_TEST_PROTOCOL_PATH,
37
37
  assertUnreachable
38
- } from "../chunk-6JN6W6G3.js";
38
+ } from "../chunk-EDCGRWSB.js";
39
39
  import {
40
40
  getLogger,
41
41
  promiseWithResolvers
42
- } from "../chunk-NWBKMCWC.js";
42
+ } from "../chunk-HK2X2UOP.js";
43
43
  import {
44
44
  INTERNAL_ERROR_CODE,
45
45
  INTERNAL_ERROR_DESCRIPTION
46
- } from "../chunk-W6RDS6NW.js";
46
+ } from "../chunk-LQOCWGP6.js";
47
47
 
48
48
  // src/driver-test-suite/mod.ts
49
49
  import { serve as honoServe } from "@hono/node-server";
@@ -150,7 +150,9 @@ function createTestInlineClientDriver(endpoint, encoding) {
150
150
  const protocols = [];
151
151
  protocols.push(WS_PROTOCOL_STANDARD);
152
152
  protocols.push(`${WS_PROTOCOL_TARGET}actor`);
153
- protocols.push(`${WS_PROTOCOL_ACTOR}${encodeURIComponent(actorId)}`);
153
+ protocols.push(
154
+ `${WS_PROTOCOL_ACTOR}${encodeURIComponent(actorId)}`
155
+ );
154
156
  protocols.push(`${WS_PROTOCOL_ENCODING}${encoding2}`);
155
157
  protocols.push(
156
158
  `${WS_TEST_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
@@ -865,23 +867,176 @@ function runActorConnTests(driverTestConfig) {
865
867
  });
866
868
  }
867
869
 
868
- // src/driver-test-suite/tests/actor-conn-state.ts
870
+ // src/driver-test-suite/tests/actor-conn-hibernation.ts
869
871
  import { describe as describe3, expect as expect3, test as test3, vi as vi3 } from "vitest";
872
+
873
+ // fixtures/driver-test-suite/hibernation.ts
874
+ var HIBERNATION_SLEEP_TIMEOUT = 500;
875
+ var hibernationActor = actor({
876
+ state: {
877
+ sleepCount: 0,
878
+ wakeCount: 0
879
+ },
880
+ createConnState: (c) => {
881
+ return {
882
+ count: 0,
883
+ connectCount: 0,
884
+ disconnectCount: 0
885
+ };
886
+ },
887
+ onWake: (c) => {
888
+ c.state.wakeCount += 1;
889
+ },
890
+ onSleep: (c) => {
891
+ c.state.sleepCount += 1;
892
+ },
893
+ onConnect: (c, conn) => {
894
+ conn.state.connectCount += 1;
895
+ },
896
+ onDisconnect: (c, conn) => {
897
+ conn.state.disconnectCount += 1;
898
+ },
899
+ actions: {
900
+ // Basic RPC that returns a simple value
901
+ ping: (c) => {
902
+ return "pong";
903
+ },
904
+ // Increment the connection's count
905
+ connIncrement: (c) => {
906
+ c.conn.state.count += 1;
907
+ return c.conn.state.count;
908
+ },
909
+ // Get the connection's count
910
+ getConnCount: (c) => {
911
+ return c.conn.state.count;
912
+ },
913
+ // Get the connection's lifecycle counts
914
+ getConnLifecycleCounts: (c) => {
915
+ return {
916
+ connectCount: c.conn.state.connectCount,
917
+ disconnectCount: c.conn.state.disconnectCount
918
+ };
919
+ },
920
+ // Get all connection IDs
921
+ getConnectionIds: (c) => {
922
+ return c.conns.entries().map((x) => x[0]).toArray();
923
+ },
924
+ // Get actor sleep/wake counts
925
+ getActorCounts: (c) => {
926
+ return {
927
+ sleepCount: c.state.sleepCount,
928
+ wakeCount: c.state.wakeCount
929
+ };
930
+ },
931
+ // Trigger sleep
932
+ triggerSleep: (c) => {
933
+ c.sleep();
934
+ }
935
+ },
936
+ options: {
937
+ sleepTimeout: HIBERNATION_SLEEP_TIMEOUT
938
+ }
939
+ });
940
+
941
+ // src/driver-test-suite/tests/actor-conn-hibernation.ts
942
+ function runActorConnHibernationTests(driverTestConfig) {
943
+ var _a;
944
+ describe3.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.hibernation)(
945
+ "Connection Hibernation",
946
+ () => {
947
+ test3("basic conn hibernation", async (c) => {
948
+ const { client } = await setupDriverTest(c, driverTestConfig);
949
+ const hibernatingActor = client.hibernationActor.getOrCreate().connect();
950
+ const ping1 = await hibernatingActor.ping();
951
+ expect3(ping1).toBe("pong");
952
+ await hibernatingActor.triggerSleep();
953
+ await waitFor(
954
+ driverTestConfig,
955
+ HIBERNATION_SLEEP_TIMEOUT + 100
956
+ );
957
+ const ping2 = await hibernatingActor.ping();
958
+ expect3(ping2).toBe("pong");
959
+ await hibernatingActor.dispose();
960
+ });
961
+ test3("conn state persists through hibernation", async (c) => {
962
+ const { client } = await setupDriverTest(c, driverTestConfig);
963
+ const hibernatingActor = client.hibernationActor.getOrCreate().connect();
964
+ const count1 = await hibernatingActor.connIncrement();
965
+ expect3(count1).toBe(1);
966
+ const count2 = await hibernatingActor.connIncrement();
967
+ expect3(count2).toBe(2);
968
+ const initialLifecycle = await hibernatingActor.getConnLifecycleCounts();
969
+ expect3(initialLifecycle.connectCount).toBe(1);
970
+ expect3(initialLifecycle.disconnectCount).toBe(0);
971
+ const initialActorCounts = await hibernatingActor.getActorCounts();
972
+ expect3(initialActorCounts.wakeCount).toBe(1);
973
+ expect3(initialActorCounts.sleepCount).toBe(0);
974
+ await hibernatingActor.triggerSleep();
975
+ await waitFor(
976
+ driverTestConfig,
977
+ HIBERNATION_SLEEP_TIMEOUT + 100
978
+ );
979
+ const count3 = await hibernatingActor.getConnCount();
980
+ expect3(count3).toBe(2);
981
+ const finalLifecycle = await hibernatingActor.getConnLifecycleCounts();
982
+ expect3(finalLifecycle.connectCount).toBe(1);
983
+ expect3(finalLifecycle.disconnectCount).toBe(0);
984
+ const finalActorCounts = await hibernatingActor.getActorCounts();
985
+ expect3(finalActorCounts.wakeCount).toBe(2);
986
+ expect3(finalActorCounts.sleepCount).toBe(1);
987
+ await hibernatingActor.dispose();
988
+ });
989
+ test3("closing connection during hibernation", async (c) => {
990
+ const { client } = await setupDriverTest(c, driverTestConfig);
991
+ const conn1 = client.hibernationActor.getOrCreate().connect();
992
+ await conn1.ping();
993
+ const connectionIds = await conn1.getConnectionIds();
994
+ expect3(connectionIds.length).toBe(1);
995
+ const conn1Id = connectionIds[0];
996
+ await conn1.triggerSleep();
997
+ await waitFor(
998
+ driverTestConfig,
999
+ HIBERNATION_SLEEP_TIMEOUT + 100
1000
+ );
1001
+ await conn1.dispose();
1002
+ await waitFor(driverTestConfig, 250);
1003
+ const conn2 = client.hibernationActor.getOrCreate().connect();
1004
+ await vi3.waitFor(
1005
+ async () => {
1006
+ const newConnectionIds = await conn2.getConnectionIds();
1007
+ expect3(newConnectionIds.length).toBe(1);
1008
+ expect3(newConnectionIds[0]).not.toBe(conn1Id);
1009
+ },
1010
+ {
1011
+ timeout: 5e3,
1012
+ interval: 100
1013
+ }
1014
+ );
1015
+ const lifecycle = await conn2.getConnLifecycleCounts();
1016
+ expect3(lifecycle.disconnectCount).toBe(0);
1017
+ await conn2.dispose();
1018
+ });
1019
+ }
1020
+ );
1021
+ }
1022
+
1023
+ // src/driver-test-suite/tests/actor-conn-state.ts
1024
+ import { describe as describe4, expect as expect4, test as test4, vi as vi4 } from "vitest";
870
1025
  function runActorConnStateTests(driverTestConfig) {
871
- describe3("Actor Connection State Tests", () => {
872
- describe3("Connection State Initialization", () => {
873
- test3("should retrieve connection state", async (c) => {
1026
+ describe4("Actor Connection State Tests", () => {
1027
+ describe4("Connection State Initialization", () => {
1028
+ test4("should retrieve connection state", async (c) => {
874
1029
  const { client } = await setupDriverTest(c, driverTestConfig);
875
1030
  const connection = client.connStateActor.getOrCreate().connect();
876
1031
  const connState = await connection.getConnectionState();
877
- expect3(connState.id).toBeDefined();
878
- expect3(connState.username).toBeDefined();
879
- expect3(connState.role).toBeDefined();
880
- expect3(connState.counter).toBeDefined();
881
- expect3(connState.createdAt).toBeDefined();
1032
+ expect4(connState.id).toBeDefined();
1033
+ expect4(connState.username).toBeDefined();
1034
+ expect4(connState.role).toBeDefined();
1035
+ expect4(connState.counter).toBeDefined();
1036
+ expect4(connState.createdAt).toBeDefined();
882
1037
  await connection.dispose();
883
1038
  });
884
- test3("should initialize connection state with custom parameters", async (c) => {
1039
+ test4("should initialize connection state with custom parameters", async (c) => {
885
1040
  const { client } = await setupDriverTest(c, driverTestConfig);
886
1041
  const connection = client.connStateActor.getOrCreate([], {
887
1042
  params: {
@@ -890,13 +1045,13 @@ function runActorConnStateTests(driverTestConfig) {
890
1045
  }
891
1046
  }).connect();
892
1047
  const connState = await connection.getConnectionState();
893
- expect3(connState.username).toBe("testuser");
894
- expect3(connState.role).toBe("admin");
1048
+ expect4(connState.username).toBe("testuser");
1049
+ expect4(connState.role).toBe("admin");
895
1050
  await connection.dispose();
896
1051
  });
897
1052
  });
898
- describe3("Connection State Management", () => {
899
- test3("should maintain unique state for each connection", async (c) => {
1053
+ describe4("Connection State Management", () => {
1054
+ test4("should maintain unique state for each connection", async (c) => {
900
1055
  const { client } = await setupDriverTest(c, driverTestConfig);
901
1056
  const conn1 = client.connStateActor.getOrCreate([], {
902
1057
  params: { username: "user1" }
@@ -908,14 +1063,14 @@ function runActorConnStateTests(driverTestConfig) {
908
1063
  await conn2.incrementConnCounter(10);
909
1064
  const state1 = await conn1.getConnectionState();
910
1065
  const state2 = await conn2.getConnectionState();
911
- expect3(state1.counter).toBe(5);
912
- expect3(state2.counter).toBe(10);
913
- expect3(state1.username).toBe("user1");
914
- expect3(state2.username).toBe("user2");
1066
+ expect4(state1.counter).toBe(5);
1067
+ expect4(state2.counter).toBe(10);
1068
+ expect4(state1.username).toBe("user1");
1069
+ expect4(state2.username).toBe("user2");
915
1070
  await conn1.dispose();
916
1071
  await conn2.dispose();
917
1072
  });
918
- test3("should track connections in shared state", async (c) => {
1073
+ test4("should track connections in shared state", async (c) => {
919
1074
  const { client } = await setupDriverTest(c, driverTestConfig);
920
1075
  const handle = client.connStateActor.getOrCreate();
921
1076
  const conn1 = handle.connect();
@@ -924,12 +1079,12 @@ function runActorConnStateTests(driverTestConfig) {
924
1079
  await conn2.getConnectionState();
925
1080
  const state1 = await conn1.getConnectionState();
926
1081
  const connectionIds = await conn1.getConnectionIds();
927
- expect3(connectionIds.length).toBeGreaterThanOrEqual(2);
928
- expect3(connectionIds).toContain(state1.id);
1082
+ expect4(connectionIds.length).toBeGreaterThanOrEqual(2);
1083
+ expect4(connectionIds).toContain(state1.id);
929
1084
  await conn1.dispose();
930
1085
  await conn2.dispose();
931
1086
  });
932
- test3("should identify different connections in the same actor", async (c) => {
1087
+ test4("should identify different connections in the same actor", async (c) => {
933
1088
  const { client } = await setupDriverTest(c, driverTestConfig);
934
1089
  const handle = client.connStateActor.getOrCreate();
935
1090
  const conn1 = handle.connect();
@@ -937,16 +1092,16 @@ function runActorConnStateTests(driverTestConfig) {
937
1092
  await conn1.getConnectionState();
938
1093
  await conn2.getConnectionState();
939
1094
  const allStates = await conn1.getAllConnectionStates();
940
- expect3(allStates.length).toBeGreaterThanOrEqual(2);
1095
+ expect4(allStates.length).toBeGreaterThanOrEqual(2);
941
1096
  const ids = allStates.map((state) => state.id);
942
1097
  const uniqueIds = [...new Set(ids)];
943
- expect3(uniqueIds.length).toBe(ids.length);
1098
+ expect4(uniqueIds.length).toBe(ids.length);
944
1099
  await conn1.dispose();
945
1100
  await conn2.dispose();
946
1101
  });
947
1102
  });
948
- describe3("Connection Lifecycle", () => {
949
- test3("should track connection and disconnection events", async (c) => {
1103
+ describe4("Connection Lifecycle", () => {
1104
+ test4("should track connection and disconnection events", async (c) => {
950
1105
  const { client } = await setupDriverTest(c, driverTestConfig);
951
1106
  const debugHandle = client.connStateActor.getOrCreate(
952
1107
  void 0,
@@ -956,21 +1111,21 @@ function runActorConnStateTests(driverTestConfig) {
956
1111
  );
957
1112
  const conn = client.connStateActor.getOrCreate().connect();
958
1113
  const connState = await conn.getConnectionState();
959
- await vi3.waitFor(async () => {
1114
+ await vi4.waitFor(async () => {
960
1115
  const connectionIds = await debugHandle.getConnectionIds();
961
- expect3(connectionIds).toContain(connState.id);
1116
+ expect4(connectionIds).toContain(connState.id);
962
1117
  });
963
- await vi3.waitFor(async () => {
1118
+ await vi4.waitFor(async () => {
964
1119
  const disconnects = await debugHandle.getDisconnectionCount();
965
- expect3(disconnects).toBe(0);
1120
+ expect4(disconnects).toBe(0);
966
1121
  });
967
1122
  await conn.dispose();
968
- await vi3.waitFor(
1123
+ await vi4.waitFor(
969
1124
  async () => {
970
1125
  console.log("disconnects before");
971
1126
  const disconnects = await debugHandle.getDisconnectionCount();
972
1127
  console.log("disconnects", disconnects);
973
- expect3(disconnects).toBe(1);
1128
+ expect4(disconnects).toBe(1);
974
1129
  },
975
1130
  // SSE takes a long time to disconnect on CF Workers
976
1131
  {
@@ -979,18 +1134,18 @@ function runActorConnStateTests(driverTestConfig) {
979
1134
  }
980
1135
  );
981
1136
  const newConn = client.connStateActor.getOrCreate().connect();
982
- await vi3.waitFor(async () => {
1137
+ await vi4.waitFor(async () => {
983
1138
  const connectionIds = await debugHandle.getConnectionIds();
984
1139
  console.log("conn ids", connectionIds);
985
- expect3(connectionIds.length).toBe(1);
1140
+ expect4(connectionIds.length).toBe(1);
986
1141
  });
987
1142
  await newConn.dispose();
988
- await vi3.waitFor(
1143
+ await vi4.waitFor(
989
1144
  async () => {
990
1145
  console.log("A");
991
1146
  const disconnects = await debugHandle.getDisconnectionCount();
992
1147
  console.log(`B ${disconnects}`);
993
- expect3(disconnects).toBe(2);
1148
+ expect4(disconnects).toBe(2);
994
1149
  },
995
1150
  // SSE takes a long time to disconnect on CF Workers
996
1151
  {
@@ -999,25 +1154,25 @@ function runActorConnStateTests(driverTestConfig) {
999
1154
  }
1000
1155
  );
1001
1156
  });
1002
- test3("should update connection state", async (c) => {
1157
+ test4("should update connection state", async (c) => {
1003
1158
  const { client } = await setupDriverTest(c, driverTestConfig);
1004
1159
  const conn = client.connStateActor.getOrCreate().connect();
1005
1160
  const initialState = await conn.getConnectionState();
1006
- expect3(initialState.username).toBe("anonymous");
1161
+ expect4(initialState.username).toBe("anonymous");
1007
1162
  const updatedState = await conn.updateConnection({
1008
1163
  username: "newname",
1009
1164
  role: "moderator"
1010
1165
  });
1011
- expect3(updatedState.username).toBe("newname");
1012
- expect3(updatedState.role).toBe("moderator");
1166
+ expect4(updatedState.username).toBe("newname");
1167
+ expect4(updatedState.role).toBe("moderator");
1013
1168
  const latestState = await conn.getConnectionState();
1014
- expect3(latestState.username).toBe("newname");
1015
- expect3(latestState.role).toBe("moderator");
1169
+ expect4(latestState.username).toBe("newname");
1170
+ expect4(latestState.role).toBe("moderator");
1016
1171
  await conn.dispose();
1017
1172
  });
1018
1173
  });
1019
- describe3("Connection Communication", () => {
1020
- test3("should send messages to specific connections", async (c) => {
1174
+ describe4("Connection Communication", () => {
1175
+ test4("should send messages to specific connections", async (c) => {
1021
1176
  const { client } = await setupDriverTest(c, driverTestConfig);
1022
1177
  const handle = client.connStateActor.getOrCreate();
1023
1178
  const conn1 = handle.connect();
@@ -1028,15 +1183,15 @@ function runActorConnStateTests(driverTestConfig) {
1028
1183
  conn2.on("directMessage", (data) => {
1029
1184
  receivedMessages.push(data);
1030
1185
  });
1031
- await vi3.waitFor(async () => {
1186
+ await vi4.waitFor(async () => {
1032
1187
  const success = await conn1.sendToConnection(
1033
1188
  state2.id,
1034
1189
  "Hello from conn1"
1035
1190
  );
1036
- expect3(success).toBe(true);
1037
- expect3(receivedMessages.length).toBe(1);
1038
- expect3(receivedMessages[0].from).toBe(state1.id);
1039
- expect3(receivedMessages[0].message).toBe(
1191
+ expect4(success).toBe(true);
1192
+ expect4(receivedMessages.length).toBe(1);
1193
+ expect4(receivedMessages[0].from).toBe(state1.id);
1194
+ expect4(receivedMessages[0].message).toBe(
1040
1195
  "Hello from conn1"
1041
1196
  );
1042
1197
  });
@@ -1048,10 +1203,10 @@ function runActorConnStateTests(driverTestConfig) {
1048
1203
  }
1049
1204
 
1050
1205
  // src/driver-test-suite/tests/actor-destroy.ts
1051
- import { describe as describe4, expect as expect4, test as test4, vi as vi4 } from "vitest";
1206
+ import { describe as describe5, expect as expect5, test as test5, vi as vi5 } from "vitest";
1052
1207
  function runActorDestroyTests(driverTestConfig) {
1053
- describe4("Actor Destroy Tests", () => {
1054
- test4("actor destroy clears state (without connect)", async (c) => {
1208
+ describe5("Actor Destroy Tests", () => {
1209
+ test5("actor destroy clears state (without connect)", async (c) => {
1055
1210
  const { client } = await setupDriverTest(c, driverTestConfig);
1056
1211
  const actorKey = "test-destroy-without-connect";
1057
1212
  const observer = client.destroyObserver.getOrCreate(["observer"]);
@@ -1059,33 +1214,33 @@ function runActorDestroyTests(driverTestConfig) {
1059
1214
  const destroyActor = client.destroyActor.getOrCreate([actorKey]);
1060
1215
  await destroyActor.setValue(42);
1061
1216
  const value = await destroyActor.getValue();
1062
- expect4(value).toBe(42);
1217
+ expect5(value).toBe(42);
1063
1218
  const actorId = await destroyActor.resolve();
1064
1219
  await destroyActor.destroy();
1065
- await vi4.waitFor(async () => {
1220
+ await vi5.waitFor(async () => {
1066
1221
  const wasDestroyed = await observer.wasDestroyed(actorKey);
1067
- expect4(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1222
+ expect5(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1068
1223
  });
1069
- await vi4.waitFor(async () => {
1224
+ await vi5.waitFor(async () => {
1070
1225
  let actorRunning = false;
1071
1226
  try {
1072
1227
  await client.destroyActor.getForId(actorId).getValue();
1073
1228
  actorRunning = true;
1074
1229
  } catch (err) {
1075
- expect4(err.group).toBe("actor");
1076
- expect4(err.code).toBe("not_found");
1230
+ expect5(err.group).toBe("actor");
1231
+ expect5(err.code).toBe("not_found");
1077
1232
  }
1078
- expect4(actorRunning, "actor still running").toBeFalsy();
1233
+ expect5(actorRunning, "actor still running").toBeFalsy();
1079
1234
  });
1080
1235
  let existsById = false;
1081
1236
  try {
1082
1237
  await client.destroyActor.getForId(actorId).getValue();
1083
1238
  existsById = true;
1084
1239
  } catch (err) {
1085
- expect4(err.group).toBe("actor");
1086
- expect4(err.code).toBe("not_found");
1240
+ expect5(err.group).toBe("actor");
1241
+ expect5(err.code).toBe("not_found");
1087
1242
  }
1088
- expect4(
1243
+ expect5(
1089
1244
  existsById,
1090
1245
  "actor should not exist after destroy"
1091
1246
  ).toBeFalsy();
@@ -1094,10 +1249,10 @@ function runActorDestroyTests(driverTestConfig) {
1094
1249
  await client.destroyActor.get(["test-destroy-without-connect"]).resolve();
1095
1250
  existsByKey = true;
1096
1251
  } catch (err) {
1097
- expect4(err.group).toBe("actor");
1098
- expect4(err.code).toBe("not_found");
1252
+ expect5(err.group).toBe("actor");
1253
+ expect5(err.code).toBe("not_found");
1099
1254
  }
1100
- expect4(
1255
+ expect5(
1101
1256
  existsByKey,
1102
1257
  "actor should not exist after destroy"
1103
1258
  ).toBeFalsy();
@@ -1105,9 +1260,9 @@ function runActorDestroyTests(driverTestConfig) {
1105
1260
  "test-destroy-without-connect"
1106
1261
  ]);
1107
1262
  const newValue = await newActor.getValue();
1108
- expect4(newValue).toBe(0);
1263
+ expect5(newValue).toBe(0);
1109
1264
  });
1110
- test4("actor destroy clears state (with connect)", async (c) => {
1265
+ test5("actor destroy clears state (with connect)", async (c) => {
1111
1266
  const { client } = await setupDriverTest(c, driverTestConfig);
1112
1267
  const actorKey = "test-destroy-with-connect";
1113
1268
  const observer = client.destroyObserver.getOrCreate(["observer"]);
@@ -1119,33 +1274,33 @@ function runActorDestroyTests(driverTestConfig) {
1119
1274
  const destroyActor = destroyActorHandle.connect();
1120
1275
  await destroyActor.setValue(99);
1121
1276
  const value = await destroyActor.getValue();
1122
- expect4(value).toBe(99);
1277
+ expect5(value).toBe(99);
1123
1278
  await destroyActor.destroy();
1124
1279
  await destroyActor.dispose();
1125
- await vi4.waitFor(async () => {
1280
+ await vi5.waitFor(async () => {
1126
1281
  const wasDestroyed = await observer.wasDestroyed(actorKey);
1127
- expect4(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1282
+ expect5(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1128
1283
  });
1129
- await vi4.waitFor(async () => {
1284
+ await vi5.waitFor(async () => {
1130
1285
  let actorRunning = false;
1131
1286
  try {
1132
1287
  await client.destroyActor.getForId(actorId).getValue();
1133
1288
  actorRunning = true;
1134
1289
  } catch (err) {
1135
- expect4(err.group).toBe("actor");
1136
- expect4(err.code).toBe("not_found");
1290
+ expect5(err.group).toBe("actor");
1291
+ expect5(err.code).toBe("not_found");
1137
1292
  }
1138
- expect4(actorRunning, "actor still running").toBeFalsy();
1293
+ expect5(actorRunning, "actor still running").toBeFalsy();
1139
1294
  });
1140
1295
  let existsById = false;
1141
1296
  try {
1142
1297
  await client.destroyActor.getForId(actorId).getValue();
1143
1298
  existsById = true;
1144
1299
  } catch (err) {
1145
- expect4(err.group).toBe("actor");
1146
- expect4(err.code).toBe("not_found");
1300
+ expect5(err.group).toBe("actor");
1301
+ expect5(err.code).toBe("not_found");
1147
1302
  }
1148
- expect4(
1303
+ expect5(
1149
1304
  existsById,
1150
1305
  "actor should not exist after destroy"
1151
1306
  ).toBeFalsy();
@@ -1154,10 +1309,10 @@ function runActorDestroyTests(driverTestConfig) {
1154
1309
  await client.destroyActor.get(["test-destroy-with-connect"]).resolve();
1155
1310
  existsByKey = true;
1156
1311
  } catch (err) {
1157
- expect4(err.group).toBe("actor");
1158
- expect4(err.code).toBe("not_found");
1312
+ expect5(err.group).toBe("actor");
1313
+ expect5(err.code).toBe("not_found");
1159
1314
  }
1160
- expect4(
1315
+ expect5(
1161
1316
  existsByKey,
1162
1317
  "actor should not exist after destroy"
1163
1318
  ).toBeFalsy();
@@ -1165,9 +1320,9 @@ function runActorDestroyTests(driverTestConfig) {
1165
1320
  "test-destroy-with-connect"
1166
1321
  ]);
1167
1322
  const newValue = await newActor.getValue();
1168
- expect4(newValue).toBe(0);
1323
+ expect5(newValue).toBe(0);
1169
1324
  });
1170
- test4("actor destroy allows recreation via getOrCreate with resolve", async (c) => {
1325
+ test5("actor destroy allows recreation via getOrCreate with resolve", async (c) => {
1171
1326
  const { client } = await setupDriverTest(c, driverTestConfig);
1172
1327
  const actorKey = "test-destroy-getorcreate-resolve";
1173
1328
  const observer = client.destroyObserver.getOrCreate(["observer"]);
@@ -1175,30 +1330,30 @@ function runActorDestroyTests(driverTestConfig) {
1175
1330
  const destroyActor = client.destroyActor.getOrCreate([actorKey]);
1176
1331
  await destroyActor.setValue(123);
1177
1332
  const value = await destroyActor.getValue();
1178
- expect4(value).toBe(123);
1333
+ expect5(value).toBe(123);
1179
1334
  const actorId = await destroyActor.resolve();
1180
1335
  await destroyActor.destroy();
1181
- await vi4.waitFor(async () => {
1336
+ await vi5.waitFor(async () => {
1182
1337
  const wasDestroyed = await observer.wasDestroyed(actorKey);
1183
- expect4(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1338
+ expect5(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1184
1339
  });
1185
- await vi4.waitFor(async () => {
1340
+ await vi5.waitFor(async () => {
1186
1341
  let actorRunning = false;
1187
1342
  try {
1188
1343
  await client.destroyActor.getForId(actorId).getValue();
1189
1344
  actorRunning = true;
1190
1345
  } catch (err) {
1191
- expect4(err.group).toBe("actor");
1192
- expect4(err.code).toBe("not_found");
1346
+ expect5(err.group).toBe("actor");
1347
+ expect5(err.code).toBe("not_found");
1193
1348
  }
1194
- expect4(actorRunning, "actor still running").toBeFalsy();
1349
+ expect5(actorRunning, "actor still running").toBeFalsy();
1195
1350
  });
1196
1351
  const newHandle = client.destroyActor.getOrCreate([actorKey]);
1197
1352
  const newActorId = await newHandle.resolve();
1198
1353
  const newValue = await newHandle.getValue();
1199
- expect4(newValue).toBe(0);
1354
+ expect5(newValue).toBe(0);
1200
1355
  });
1201
- test4("actor destroy allows recreation via create", async (c) => {
1356
+ test5("actor destroy allows recreation via create", async (c) => {
1202
1357
  const { client } = await setupDriverTest(c, driverTestConfig);
1203
1358
  const actorKey = "test-destroy-create";
1204
1359
  const observer = client.destroyObserver.getOrCreate(["observer"]);
@@ -1206,44 +1361,44 @@ function runActorDestroyTests(driverTestConfig) {
1206
1361
  const initialHandle = await client.destroyActor.create([actorKey]);
1207
1362
  await initialHandle.setValue(456);
1208
1363
  const value = await initialHandle.getValue();
1209
- expect4(value).toBe(456);
1364
+ expect5(value).toBe(456);
1210
1365
  const actorId = await initialHandle.resolve();
1211
1366
  await initialHandle.destroy();
1212
- await vi4.waitFor(async () => {
1367
+ await vi5.waitFor(async () => {
1213
1368
  const wasDestroyed = await observer.wasDestroyed(actorKey);
1214
- expect4(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1369
+ expect5(wasDestroyed, "actor onDestroy not called").toBeTruthy();
1215
1370
  });
1216
- await vi4.waitFor(async () => {
1371
+ await vi5.waitFor(async () => {
1217
1372
  let actorRunning = false;
1218
1373
  try {
1219
1374
  await client.destroyActor.getForId(actorId).getValue();
1220
1375
  actorRunning = true;
1221
1376
  } catch (err) {
1222
- expect4(err.group).toBe("actor");
1223
- expect4(err.code).toBe("not_found");
1377
+ expect5(err.group).toBe("actor");
1378
+ expect5(err.code).toBe("not_found");
1224
1379
  }
1225
- expect4(actorRunning, "actor still running").toBeFalsy();
1380
+ expect5(actorRunning, "actor still running").toBeFalsy();
1226
1381
  });
1227
1382
  const newHandle = await client.destroyActor.create([actorKey]);
1228
1383
  const newActorId = await newHandle.resolve();
1229
1384
  const newValue = await newHandle.getValue();
1230
- expect4(newValue).toBe(0);
1385
+ expect5(newValue).toBe(0);
1231
1386
  });
1232
1387
  });
1233
1388
  }
1234
1389
 
1235
1390
  // src/driver-test-suite/tests/actor-driver.ts
1236
- import { describe as describe8 } from "vitest";
1391
+ import { describe as describe9 } from "vitest";
1237
1392
 
1238
1393
  // src/driver-test-suite/tests/actor-schedule.ts
1239
- import { describe as describe5, expect as expect5, test as test5 } from "vitest";
1394
+ import { describe as describe6, expect as expect6, test as test6 } from "vitest";
1240
1395
  function runActorScheduleTests(driverTestConfig) {
1241
1396
  var _a;
1242
- describe5.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.schedule)(
1397
+ describe6.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.schedule)(
1243
1398
  "Actor Schedule Tests",
1244
1399
  () => {
1245
- describe5("Scheduled Alarms", () => {
1246
- test5("executes c.schedule.at() with specific timestamp", async (c) => {
1400
+ describe6("Scheduled Alarms", () => {
1401
+ test6("executes c.schedule.at() with specific timestamp", async (c) => {
1247
1402
  const { client } = await setupDriverTest(
1248
1403
  c,
1249
1404
  driverTestConfig
@@ -1254,10 +1409,10 @@ function runActorScheduleTests(driverTestConfig) {
1254
1409
  await waitFor(driverTestConfig, 500);
1255
1410
  const lastRun = await scheduled.getLastRun();
1256
1411
  const scheduledCount = await scheduled.getScheduledCount();
1257
- expect5(lastRun).toBeGreaterThan(0);
1258
- expect5(scheduledCount).toBe(1);
1412
+ expect6(lastRun).toBeGreaterThan(0);
1413
+ expect6(scheduledCount).toBe(1);
1259
1414
  });
1260
- test5("executes c.schedule.after() with delay", async (c) => {
1415
+ test6("executes c.schedule.after() with delay", async (c) => {
1261
1416
  const { client } = await setupDriverTest(
1262
1417
  c,
1263
1418
  driverTestConfig
@@ -1267,10 +1422,10 @@ function runActorScheduleTests(driverTestConfig) {
1267
1422
  await waitFor(driverTestConfig, 500);
1268
1423
  const lastRun = await scheduled.getLastRun();
1269
1424
  const scheduledCount = await scheduled.getScheduledCount();
1270
- expect5(lastRun).toBeGreaterThan(0);
1271
- expect5(scheduledCount).toBe(1);
1425
+ expect6(lastRun).toBeGreaterThan(0);
1426
+ expect6(scheduledCount).toBe(1);
1272
1427
  });
1273
- test5("multiple scheduled tasks execute in order", async (c) => {
1428
+ test6("multiple scheduled tasks execute in order", async (c) => {
1274
1429
  const { client } = await setupDriverTest(
1275
1430
  c,
1276
1431
  driverTestConfig
@@ -1282,13 +1437,13 @@ function runActorScheduleTests(driverTestConfig) {
1282
1437
  await scheduled.scheduleTaskAfterWithId("third", 1250);
1283
1438
  await waitFor(driverTestConfig, 500);
1284
1439
  const history1 = await scheduled.getTaskHistory();
1285
- expect5(history1).toEqual(["first"]);
1440
+ expect6(history1).toEqual(["first"]);
1286
1441
  await waitFor(driverTestConfig, 500);
1287
1442
  const history2 = await scheduled.getTaskHistory();
1288
- expect5(history2).toEqual(["first", "second"]);
1443
+ expect6(history2).toEqual(["first", "second"]);
1289
1444
  await waitFor(driverTestConfig, 500);
1290
1445
  const history3 = await scheduled.getTaskHistory();
1291
- expect5(history3).toEqual(["first", "second", "third"]);
1446
+ expect6(history3).toEqual(["first", "second", "third"]);
1292
1447
  });
1293
1448
  });
1294
1449
  }
@@ -1296,7 +1451,7 @@ function runActorScheduleTests(driverTestConfig) {
1296
1451
  }
1297
1452
 
1298
1453
  // src/driver-test-suite/tests/actor-sleep.ts
1299
- import { describe as describe6, expect as expect6, test as test6 } from "vitest";
1454
+ import { describe as describe7, expect as expect7, test as test7 } from "vitest";
1300
1455
 
1301
1456
  // fixtures/driver-test-suite/sleep.ts
1302
1457
  var SLEEP_TIMEOUT = 1e3;
@@ -1486,30 +1641,30 @@ var sleepWithNoSleepOption = actor({
1486
1641
  // src/driver-test-suite/tests/actor-sleep.ts
1487
1642
  function runActorSleepTests(driverTestConfig) {
1488
1643
  var _a;
1489
- describe6.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.sleep)("Actor Sleep Tests", () => {
1490
- test6("actor sleep persists state", async (c) => {
1644
+ describe7.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.sleep)("Actor Sleep Tests", () => {
1645
+ test7("actor sleep persists state", async (c) => {
1491
1646
  const { client } = await setupDriverTest(c, driverTestConfig);
1492
1647
  const sleepActor = client.sleep.getOrCreate();
1493
1648
  {
1494
1649
  const { startCount, sleepCount } = await sleepActor.getCounts();
1495
- expect6(sleepCount).toBe(0);
1496
- expect6(startCount).toBe(1);
1650
+ expect7(sleepCount).toBe(0);
1651
+ expect7(startCount).toBe(1);
1497
1652
  }
1498
1653
  await sleepActor.triggerSleep();
1499
1654
  await waitFor(driverTestConfig, 250);
1500
1655
  {
1501
1656
  const { startCount, sleepCount } = await sleepActor.getCounts();
1502
- expect6(sleepCount).toBe(1);
1503
- expect6(startCount).toBe(2);
1657
+ expect7(sleepCount).toBe(1);
1658
+ expect7(startCount).toBe(2);
1504
1659
  }
1505
1660
  });
1506
- test6("actor sleep persists state with connect", async (c) => {
1661
+ test7("actor sleep persists state with connect", async (c) => {
1507
1662
  const { client } = await setupDriverTest(c, driverTestConfig);
1508
1663
  const sleepActor = client.sleep.getOrCreate().connect();
1509
1664
  {
1510
1665
  const { startCount, sleepCount } = await sleepActor.getCounts();
1511
- expect6(sleepCount).toBe(0);
1512
- expect6(startCount).toBe(1);
1666
+ expect7(sleepCount).toBe(0);
1667
+ expect7(startCount).toBe(1);
1513
1668
  }
1514
1669
  await sleepActor.triggerSleep();
1515
1670
  await sleepActor.dispose();
@@ -1517,108 +1672,108 @@ function runActorSleepTests(driverTestConfig) {
1517
1672
  const sleepActor2 = client.sleep.getOrCreate();
1518
1673
  {
1519
1674
  const { startCount, sleepCount } = await sleepActor2.getCounts();
1520
- expect6(sleepCount).toBe(1);
1521
- expect6(startCount).toBe(2);
1675
+ expect7(sleepCount).toBe(1);
1676
+ expect7(startCount).toBe(2);
1522
1677
  }
1523
1678
  });
1524
- test6("actor automatically sleeps after timeout", async (c) => {
1679
+ test7("actor automatically sleeps after timeout", async (c) => {
1525
1680
  const { client } = await setupDriverTest(c, driverTestConfig);
1526
1681
  const sleepActor = client.sleep.getOrCreate();
1527
1682
  {
1528
1683
  const { startCount, sleepCount } = await sleepActor.getCounts();
1529
- expect6(sleepCount).toBe(0);
1530
- expect6(startCount).toBe(1);
1684
+ expect7(sleepCount).toBe(0);
1685
+ expect7(startCount).toBe(1);
1531
1686
  }
1532
1687
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1533
1688
  {
1534
1689
  const { startCount, sleepCount } = await sleepActor.getCounts();
1535
- expect6(sleepCount).toBe(1);
1536
- expect6(startCount).toBe(2);
1690
+ expect7(sleepCount).toBe(1);
1691
+ expect7(startCount).toBe(2);
1537
1692
  }
1538
1693
  });
1539
- test6("actor automatically sleeps after timeout with connect", async (c) => {
1694
+ test7("actor automatically sleeps after timeout with connect", async (c) => {
1540
1695
  const { client } = await setupDriverTest(c, driverTestConfig);
1541
1696
  const sleepActor = client.sleep.getOrCreate().connect();
1542
1697
  {
1543
1698
  const { startCount, sleepCount } = await sleepActor.getCounts();
1544
- expect6(sleepCount).toBe(0);
1545
- expect6(startCount).toBe(1);
1699
+ expect7(sleepCount).toBe(0);
1700
+ expect7(startCount).toBe(1);
1546
1701
  }
1547
1702
  await sleepActor.dispose();
1548
1703
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1549
1704
  const sleepActor2 = client.sleep.getOrCreate();
1550
1705
  {
1551
1706
  const { startCount, sleepCount } = await sleepActor2.getCounts();
1552
- expect6(sleepCount).toBe(1);
1553
- expect6(startCount).toBe(2);
1707
+ expect7(sleepCount).toBe(1);
1708
+ expect7(startCount).toBe(2);
1554
1709
  }
1555
1710
  });
1556
- test6("rpc calls keep actor awake", async (c) => {
1711
+ test7("rpc calls keep actor awake", async (c) => {
1557
1712
  const { client } = await setupDriverTest(c, driverTestConfig);
1558
1713
  const sleepActor = client.sleep.getOrCreate();
1559
1714
  {
1560
1715
  const { startCount, sleepCount } = await sleepActor.getCounts();
1561
- expect6(sleepCount).toBe(0);
1562
- expect6(startCount).toBe(1);
1716
+ expect7(sleepCount).toBe(0);
1717
+ expect7(startCount).toBe(1);
1563
1718
  }
1564
1719
  await waitFor(driverTestConfig, SLEEP_TIMEOUT - 250);
1565
1720
  {
1566
1721
  const { startCount, sleepCount } = await sleepActor.getCounts();
1567
- expect6(sleepCount).toBe(0);
1568
- expect6(startCount).toBe(1);
1722
+ expect7(sleepCount).toBe(0);
1723
+ expect7(startCount).toBe(1);
1569
1724
  }
1570
1725
  await waitFor(driverTestConfig, SLEEP_TIMEOUT - 250);
1571
1726
  {
1572
1727
  const { startCount, sleepCount } = await sleepActor.getCounts();
1573
- expect6(sleepCount).toBe(0);
1574
- expect6(startCount).toBe(1);
1728
+ expect7(sleepCount).toBe(0);
1729
+ expect7(startCount).toBe(1);
1575
1730
  }
1576
1731
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1577
1732
  {
1578
1733
  const { startCount, sleepCount } = await sleepActor.getCounts();
1579
- expect6(sleepCount).toBe(1);
1580
- expect6(startCount).toBe(2);
1734
+ expect7(sleepCount).toBe(1);
1735
+ expect7(startCount).toBe(2);
1581
1736
  }
1582
1737
  });
1583
- test6("alarms keep actor awake", async (c) => {
1738
+ test7("alarms keep actor awake", async (c) => {
1584
1739
  const { client } = await setupDriverTest(c, driverTestConfig);
1585
1740
  const sleepActor = client.sleep.getOrCreate();
1586
1741
  {
1587
1742
  const { startCount, sleepCount } = await sleepActor.getCounts();
1588
- expect6(sleepCount).toBe(0);
1589
- expect6(startCount).toBe(1);
1743
+ expect7(sleepCount).toBe(0);
1744
+ expect7(startCount).toBe(1);
1590
1745
  }
1591
1746
  await sleepActor.setAlarm(SLEEP_TIMEOUT - 250);
1592
1747
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1593
1748
  {
1594
1749
  const { startCount, sleepCount } = await sleepActor.getCounts();
1595
- expect6(sleepCount).toBe(0);
1596
- expect6(startCount).toBe(1);
1750
+ expect7(sleepCount).toBe(0);
1751
+ expect7(startCount).toBe(1);
1597
1752
  }
1598
1753
  });
1599
- test6("alarms wake actors", async (c) => {
1754
+ test7("alarms wake actors", async (c) => {
1600
1755
  const { client } = await setupDriverTest(c, driverTestConfig);
1601
1756
  const sleepActor = client.sleep.getOrCreate();
1602
1757
  {
1603
1758
  const { startCount, sleepCount } = await sleepActor.getCounts();
1604
- expect6(sleepCount).toBe(0);
1605
- expect6(startCount).toBe(1);
1759
+ expect7(sleepCount).toBe(0);
1760
+ expect7(startCount).toBe(1);
1606
1761
  }
1607
1762
  await sleepActor.setAlarm(SLEEP_TIMEOUT + 250);
1608
1763
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 200);
1609
1764
  {
1610
1765
  const { startCount, sleepCount } = await sleepActor.getCounts();
1611
- expect6(sleepCount).toBe(1);
1612
- expect6(startCount).toBe(2);
1766
+ expect7(sleepCount).toBe(1);
1767
+ expect7(startCount).toBe(2);
1613
1768
  }
1614
1769
  });
1615
- test6("long running rpcs keep actor awake", async (c) => {
1770
+ test7("long running rpcs keep actor awake", async (c) => {
1616
1771
  const { client } = await setupDriverTest(c, driverTestConfig);
1617
1772
  const sleepActor = client.sleepWithLongRpc.getOrCreate().connect();
1618
1773
  {
1619
1774
  const { startCount, sleepCount } = await sleepActor.getCounts();
1620
- expect6(sleepCount).toBe(0);
1621
- expect6(startCount).toBe(1);
1775
+ expect7(sleepCount).toBe(0);
1776
+ expect7(startCount).toBe(1);
1622
1777
  }
1623
1778
  const waitPromise = new Promise(
1624
1779
  (resolve) => sleepActor.once("waiting", resolve)
@@ -1630,19 +1785,19 @@ function runActorSleepTests(driverTestConfig) {
1630
1785
  await longRunningPromise;
1631
1786
  {
1632
1787
  const { startCount, sleepCount } = await sleepActor.getCounts();
1633
- expect6(sleepCount).toBe(0);
1634
- expect6(startCount).toBe(1);
1788
+ expect7(sleepCount).toBe(0);
1789
+ expect7(startCount).toBe(1);
1635
1790
  }
1636
1791
  await sleepActor.dispose();
1637
1792
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1638
1793
  const sleepActor2 = client.sleepWithLongRpc.getOrCreate();
1639
1794
  {
1640
1795
  const { startCount, sleepCount } = await sleepActor2.getCounts();
1641
- expect6(sleepCount).toBe(1);
1642
- expect6(startCount).toBe(2);
1796
+ expect7(sleepCount).toBe(1);
1797
+ expect7(startCount).toBe(2);
1643
1798
  }
1644
1799
  });
1645
- test6("active raw websockets keep actor awake", async (c) => {
1800
+ test7("active raw websockets keep actor awake", async (c) => {
1646
1801
  const { client, endpoint: baseUrl } = await setupDriverTest(
1647
1802
  c,
1648
1803
  driverTestConfig
@@ -1650,8 +1805,8 @@ function runActorSleepTests(driverTestConfig) {
1650
1805
  const sleepActor = client.sleepWithRawWebSocket.getOrCreate();
1651
1806
  {
1652
1807
  const { startCount, sleepCount } = await sleepActor.getCounts();
1653
- expect6(sleepCount).toBe(0);
1654
- expect6(startCount).toBe(1);
1808
+ expect7(sleepCount).toBe(0);
1809
+ expect7(startCount).toBe(1);
1655
1810
  }
1656
1811
  const ws = await sleepActor.websocket();
1657
1812
  await new Promise((resolve, reject) => {
@@ -1676,17 +1831,17 @@ function runActorSleepTests(driverTestConfig) {
1676
1831
  }
1677
1832
  };
1678
1833
  });
1679
- expect6(counts.sleepCount).toBe(0);
1680
- expect6(counts.startCount).toBe(1);
1834
+ expect7(counts.sleepCount).toBe(0);
1835
+ expect7(counts.startCount).toBe(1);
1681
1836
  ws.close();
1682
1837
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1683
1838
  {
1684
1839
  const { startCount, sleepCount } = await sleepActor.getCounts();
1685
- expect6(sleepCount).toBe(1);
1686
- expect6(startCount).toBe(2);
1840
+ expect7(sleepCount).toBe(1);
1841
+ expect7(startCount).toBe(2);
1687
1842
  }
1688
1843
  });
1689
- test6("active raw fetch requests keep actor awake", async (c) => {
1844
+ test7("active raw fetch requests keep actor awake", async (c) => {
1690
1845
  const { client, endpoint: baseUrl } = await setupDriverTest(
1691
1846
  c,
1692
1847
  driverTestConfig
@@ -1694,8 +1849,8 @@ function runActorSleepTests(driverTestConfig) {
1694
1849
  const sleepActor = client.sleepWithRawHttp.getOrCreate();
1695
1850
  {
1696
1851
  const { startCount, sleepCount } = await sleepActor.getCounts();
1697
- expect6(sleepCount).toBe(0);
1698
- expect6(startCount).toBe(1);
1852
+ expect7(sleepCount).toBe(0);
1853
+ expect7(startCount).toBe(1);
1699
1854
  }
1700
1855
  const fetchDuration = SLEEP_TIMEOUT + 250;
1701
1856
  const fetchPromise = sleepActor.fetch(
@@ -1703,67 +1858,67 @@ function runActorSleepTests(driverTestConfig) {
1703
1858
  );
1704
1859
  const response = await fetchPromise;
1705
1860
  const result = await response.json();
1706
- expect6(result.completed).toBe(true);
1861
+ expect7(result.completed).toBe(true);
1707
1862
  {
1708
1863
  const { startCount, sleepCount, requestCount } = await sleepActor.getCounts();
1709
- expect6(sleepCount).toBe(0);
1710
- expect6(startCount).toBe(1);
1711
- expect6(requestCount).toBe(1);
1864
+ expect7(sleepCount).toBe(0);
1865
+ expect7(startCount).toBe(1);
1866
+ expect7(requestCount).toBe(1);
1712
1867
  }
1713
1868
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1714
1869
  {
1715
1870
  const { startCount, sleepCount } = await sleepActor.getCounts();
1716
- expect6(sleepCount).toBe(1);
1717
- expect6(startCount).toBe(2);
1871
+ expect7(sleepCount).toBe(1);
1872
+ expect7(startCount).toBe(2);
1718
1873
  }
1719
1874
  });
1720
- test6("noSleep option disables sleeping", async (c) => {
1875
+ test7("noSleep option disables sleeping", async (c) => {
1721
1876
  const { client } = await setupDriverTest(c, driverTestConfig);
1722
1877
  const sleepActor = client.sleepWithNoSleepOption.getOrCreate();
1723
1878
  {
1724
1879
  const { startCount, sleepCount } = await sleepActor.getCounts();
1725
- expect6(sleepCount).toBe(0);
1726
- expect6(startCount).toBe(1);
1880
+ expect7(sleepCount).toBe(0);
1881
+ expect7(startCount).toBe(1);
1727
1882
  }
1728
1883
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1729
1884
  {
1730
1885
  const { startCount, sleepCount } = await sleepActor.getCounts();
1731
- expect6(sleepCount).toBe(0);
1732
- expect6(startCount).toBe(1);
1886
+ expect7(sleepCount).toBe(0);
1887
+ expect7(startCount).toBe(1);
1733
1888
  }
1734
1889
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
1735
1890
  {
1736
1891
  const { startCount, sleepCount } = await sleepActor.getCounts();
1737
- expect6(sleepCount).toBe(0);
1738
- expect6(startCount).toBe(1);
1892
+ expect7(sleepCount).toBe(0);
1893
+ expect7(startCount).toBe(1);
1739
1894
  }
1740
1895
  });
1741
1896
  });
1742
1897
  }
1743
1898
 
1744
1899
  // src/driver-test-suite/tests/actor-state.ts
1745
- import { describe as describe7, expect as expect7, test as test7 } from "vitest";
1900
+ import { describe as describe8, expect as expect8, test as test8 } from "vitest";
1746
1901
  function runActorStateTests(driverTestConfig) {
1747
- describe7("Actor State Tests", () => {
1748
- describe7("State Persistence", () => {
1749
- test7("persists state between actor instances", async (c) => {
1902
+ describe8("Actor State Tests", () => {
1903
+ describe8("State Persistence", () => {
1904
+ test8("persists state between actor instances", async (c) => {
1750
1905
  const { client } = await setupDriverTest(c, driverTestConfig);
1751
1906
  const counterInstance = client.counter.getOrCreate();
1752
1907
  const initialCount = await counterInstance.increment(5);
1753
- expect7(initialCount).toBe(5);
1908
+ expect8(initialCount).toBe(5);
1754
1909
  const sameInstance = client.counter.getOrCreate();
1755
1910
  const persistedCount = await sameInstance.increment(3);
1756
- expect7(persistedCount).toBe(8);
1911
+ expect8(persistedCount).toBe(8);
1757
1912
  });
1758
- test7("restores state after actor disconnect/reconnect", async (c) => {
1913
+ test8("restores state after actor disconnect/reconnect", async (c) => {
1759
1914
  const { client } = await setupDriverTest(c, driverTestConfig);
1760
1915
  const counterInstance = client.counter.getOrCreate();
1761
1916
  await counterInstance.increment(5);
1762
1917
  const reconnectedInstance = client.counter.getOrCreate();
1763
1918
  const persistedCount = await reconnectedInstance.increment(0);
1764
- expect7(persistedCount).toBe(5);
1919
+ expect8(persistedCount).toBe(5);
1765
1920
  });
1766
- test7("maintains separate state for different actors", async (c) => {
1921
+ test8("maintains separate state for different actors", async (c) => {
1767
1922
  const { client } = await setupDriverTest(c, driverTestConfig);
1768
1923
  const counterA = client.counter.getOrCreate(["counter-a"]);
1769
1924
  await counterA.increment(5);
@@ -1771,8 +1926,8 @@ function runActorStateTests(driverTestConfig) {
1771
1926
  await counterB.increment(10);
1772
1927
  const countA = await counterA.increment(0);
1773
1928
  const countB = await counterB.increment(0);
1774
- expect7(countA).toBe(5);
1775
- expect7(countB).toBe(10);
1929
+ expect8(countA).toBe(5);
1930
+ expect8(countB).toBe(10);
1776
1931
  });
1777
1932
  });
1778
1933
  });
@@ -1780,7 +1935,7 @@ function runActorStateTests(driverTestConfig) {
1780
1935
 
1781
1936
  // src/driver-test-suite/tests/actor-driver.ts
1782
1937
  function runActorDriverTests(driverTestConfig) {
1783
- describe8("Actor Driver Tests", () => {
1938
+ describe9("Actor Driver Tests", () => {
1784
1939
  runActorStateTests(driverTestConfig);
1785
1940
  runActorScheduleTests(driverTestConfig);
1786
1941
  runActorSleepTests(driverTestConfig);
@@ -1788,82 +1943,82 @@ function runActorDriverTests(driverTestConfig) {
1788
1943
  }
1789
1944
 
1790
1945
  // src/driver-test-suite/tests/actor-error-handling.ts
1791
- import { describe as describe9, expect as expect8, test as test8 } from "vitest";
1946
+ import { describe as describe10, expect as expect9, test as test9 } from "vitest";
1792
1947
  function runActorErrorHandlingTests(driverTestConfig) {
1793
- describe9("Actor Error Handling Tests", () => {
1794
- describe9("UserError Handling", () => {
1795
- test8("should handle simple UserError with message", async (c) => {
1948
+ describe10("Actor Error Handling Tests", () => {
1949
+ describe10("UserError Handling", () => {
1950
+ test9("should handle simple UserError with message", async (c) => {
1796
1951
  const { client } = await setupDriverTest(c, driverTestConfig);
1797
1952
  const handle = client.errorHandlingActor.getOrCreate();
1798
1953
  try {
1799
1954
  await handle.throwSimpleError();
1800
- expect8(true).toBe(false);
1955
+ expect9(true).toBe(false);
1801
1956
  } catch (error) {
1802
- expect8(error.message).toBe("Simple error message");
1803
- expect8(error.code).toBe("user_error");
1804
- expect8(error.metadata).toBeUndefined();
1957
+ expect9(error.message).toBe("Simple error message");
1958
+ expect9(error.code).toBe("user_error");
1959
+ expect9(error.metadata).toBeUndefined();
1805
1960
  }
1806
1961
  });
1807
- test8("should handle detailed UserError with code and metadata", async (c) => {
1962
+ test9("should handle detailed UserError with code and metadata", async (c) => {
1808
1963
  const { client } = await setupDriverTest(c, driverTestConfig);
1809
1964
  const handle = client.errorHandlingActor.getOrCreate();
1810
1965
  try {
1811
1966
  await handle.throwDetailedError();
1812
- expect8(true).toBe(false);
1967
+ expect9(true).toBe(false);
1813
1968
  } catch (error) {
1814
- expect8(error.message).toBe("Detailed error message");
1815
- expect8(error.code).toBe("detailed_error");
1816
- expect8(error.metadata).toBeDefined();
1817
- expect8(error.metadata.reason).toBe("test");
1818
- expect8(error.metadata.timestamp).toBeDefined();
1969
+ expect9(error.message).toBe("Detailed error message");
1970
+ expect9(error.code).toBe("detailed_error");
1971
+ expect9(error.metadata).toBeDefined();
1972
+ expect9(error.metadata.reason).toBe("test");
1973
+ expect9(error.metadata.timestamp).toBeDefined();
1819
1974
  }
1820
1975
  });
1821
1976
  });
1822
- describe9("Internal Error Handling", () => {
1823
- test8("should convert internal errors to safe format", async (c) => {
1977
+ describe10("Internal Error Handling", () => {
1978
+ test9("should convert internal errors to safe format", async (c) => {
1824
1979
  const { client } = await setupDriverTest(c, driverTestConfig);
1825
1980
  const handle = client.errorHandlingActor.getOrCreate();
1826
1981
  try {
1827
1982
  await handle.throwInternalError();
1828
- expect8(true).toBe(false);
1983
+ expect9(true).toBe(false);
1829
1984
  } catch (error) {
1830
- expect8(error.code).toBe(INTERNAL_ERROR_CODE);
1831
- expect8(error.message).toBe(INTERNAL_ERROR_DESCRIPTION);
1985
+ expect9(error.code).toBe(INTERNAL_ERROR_CODE);
1986
+ expect9(error.message).toBe(INTERNAL_ERROR_DESCRIPTION);
1832
1987
  }
1833
1988
  });
1834
1989
  });
1835
- describe9.skip("Action Timeout", () => {
1836
- test8("should handle action timeouts with custom duration", async (c) => {
1990
+ describe10.skip("Action Timeout", () => {
1991
+ test9("should handle action timeouts with custom duration", async (c) => {
1837
1992
  const { client } = await setupDriverTest(c, driverTestConfig);
1838
1993
  const handle = client.errorHandlingActor.getOrCreate();
1839
1994
  const timeoutPromise = handle.timeoutAction();
1840
1995
  try {
1841
1996
  await timeoutPromise;
1842
- expect8(true).toBe(false);
1997
+ expect9(true).toBe(false);
1843
1998
  } catch (error) {
1844
- expect8(error.message).toMatch(/timed out/i);
1999
+ expect9(error.message).toMatch(/timed out/i);
1845
2000
  }
1846
2001
  });
1847
- test8("should successfully run actions within timeout", async (c) => {
2002
+ test9("should successfully run actions within timeout", async (c) => {
1848
2003
  const { client } = await setupDriverTest(c, driverTestConfig);
1849
2004
  const handle = client.errorHandlingActor.getOrCreate();
1850
2005
  const result = await handle.delayedAction(200);
1851
- expect8(result).toBe("Completed after 200ms");
2006
+ expect9(result).toBe("Completed after 200ms");
1852
2007
  });
1853
- test8("should respect different timeouts for different actors", async (c) => {
2008
+ test9("should respect different timeouts for different actors", async (c) => {
1854
2009
  const { client } = await setupDriverTest(c, driverTestConfig);
1855
2010
  try {
1856
2011
  await client.customTimeoutActor.getOrCreate().slowAction();
1857
- expect8(true).toBe(false);
2012
+ expect9(true).toBe(false);
1858
2013
  } catch (error) {
1859
- expect8(error.message).toMatch(/timed out/i);
2014
+ expect9(error.message).toMatch(/timed out/i);
1860
2015
  }
1861
2016
  const quickResult = await client.customTimeoutActor.getOrCreate().quickAction();
1862
- expect8(quickResult).toBe("Quick action completed");
2017
+ expect9(quickResult).toBe("Quick action completed");
1863
2018
  });
1864
2019
  });
1865
- describe9("Error Recovery", () => {
1866
- test8("should continue working after errors", async (c) => {
2020
+ describe10("Error Recovery", () => {
2021
+ test9("should continue working after errors", async (c) => {
1867
2022
  const { client } = await setupDriverTest(c, driverTestConfig);
1868
2023
  const handle = client.errorHandlingActor.getOrCreate();
1869
2024
  try {
@@ -1871,27 +2026,27 @@ function runActorErrorHandlingTests(driverTestConfig) {
1871
2026
  } catch (error) {
1872
2027
  }
1873
2028
  const result = await handle.successfulAction();
1874
- expect8(result).toBe("success");
2029
+ expect9(result).toBe("success");
1875
2030
  });
1876
2031
  });
1877
2032
  });
1878
2033
  }
1879
2034
 
1880
2035
  // src/driver-test-suite/tests/actor-handle.ts
1881
- import { describe as describe10, expect as expect9, test as test9 } from "vitest";
2036
+ import { describe as describe11, expect as expect10, test as test10 } from "vitest";
1882
2037
  function runActorHandleTests(driverTestConfig) {
1883
- describe10("Actor Handle Tests", () => {
1884
- describe10("Access Methods", () => {
1885
- test9("should use .get() to access a actor", async (c) => {
2038
+ describe11("Actor Handle Tests", () => {
2039
+ describe11("Access Methods", () => {
2040
+ test10("should use .get() to access a actor", async (c) => {
1886
2041
  const { client } = await setupDriverTest(c, driverTestConfig);
1887
2042
  await client.counter.create(["test-get-handle"]);
1888
2043
  const handle = client.counter.get(["test-get-handle"]);
1889
2044
  const count = await handle.increment(5);
1890
- expect9(count).toBe(5);
2045
+ expect10(count).toBe(5);
1891
2046
  const retrievedCount = await handle.getCount();
1892
- expect9(retrievedCount).toBe(5);
2047
+ expect10(retrievedCount).toBe(5);
1893
2048
  });
1894
- test9("should use .getForId() to access a actor by ID", async (c) => {
2049
+ test10("should use .getForId() to access a actor by ID", async (c) => {
1895
2050
  const { client } = await setupDriverTest(c, driverTestConfig);
1896
2051
  const handle = client.counter.getOrCreate([
1897
2052
  "test-get-for-id-handle"
@@ -1900,73 +2055,73 @@ function runActorHandleTests(driverTestConfig) {
1900
2055
  const actorId = await handle.resolve();
1901
2056
  const idHandle = client.counter.getForId(actorId);
1902
2057
  const count = await idHandle.getCount();
1903
- expect9(count).toBe(3);
2058
+ expect10(count).toBe(3);
1904
2059
  const newCount = await idHandle.increment(4);
1905
- expect9(newCount).toBe(7);
2060
+ expect10(newCount).toBe(7);
1906
2061
  });
1907
- test9("should use .getOrCreate() to access or create a actor", async (c) => {
2062
+ test10("should use .getOrCreate() to access or create a actor", async (c) => {
1908
2063
  const { client } = await setupDriverTest(c, driverTestConfig);
1909
2064
  const handle = client.counter.getOrCreate([
1910
2065
  "test-get-or-create-handle"
1911
2066
  ]);
1912
2067
  const count = await handle.increment(7);
1913
- expect9(count).toBe(7);
2068
+ expect10(count).toBe(7);
1914
2069
  const sameHandle = client.counter.getOrCreate([
1915
2070
  "test-get-or-create-handle"
1916
2071
  ]);
1917
2072
  const retrievedCount = await sameHandle.getCount();
1918
- expect9(retrievedCount).toBe(7);
2073
+ expect10(retrievedCount).toBe(7);
1919
2074
  });
1920
- test9("should use (await create()) to create and return a handle", async (c) => {
2075
+ test10("should use (await create()) to create and return a handle", async (c) => {
1921
2076
  const { client } = await setupDriverTest(c, driverTestConfig);
1922
2077
  const handle = await client.counter.create([
1923
2078
  "test-create-handle"
1924
2079
  ]);
1925
2080
  const count = await handle.increment(9);
1926
- expect9(count).toBe(9);
2081
+ expect10(count).toBe(9);
1927
2082
  const retrievedCount = await handle.getCount();
1928
- expect9(retrievedCount).toBe(9);
2083
+ expect10(retrievedCount).toBe(9);
1929
2084
  });
1930
- test9("errors when calling create twice with the same key", async (c) => {
2085
+ test10("errors when calling create twice with the same key", async (c) => {
1931
2086
  const { client } = await setupDriverTest(c, driverTestConfig);
1932
2087
  const key = ["duplicate-create-handle", crypto.randomUUID()];
1933
2088
  await client.counter.create(key);
1934
2089
  try {
1935
2090
  await client.counter.create(key);
1936
- expect9.fail("did not error on duplicate create");
2091
+ expect10.fail("did not error on duplicate create");
1937
2092
  } catch (err) {
1938
- expect9(err.group).toBe("actor");
1939
- expect9(err.code).toBe("duplicate_key");
2093
+ expect10(err.group).toBe("actor");
2094
+ expect10(err.code).toBe("duplicate_key");
1940
2095
  }
1941
2096
  });
1942
- test9(".get().resolve() errors for non-existent actor", async (c) => {
2097
+ test10(".get().resolve() errors for non-existent actor", async (c) => {
1943
2098
  const { client } = await setupDriverTest(c, driverTestConfig);
1944
2099
  const missingId = `nonexistent-${crypto.randomUUID()}`;
1945
2100
  try {
1946
2101
  await client.counter.get([missingId]).resolve();
1947
- expect9.fail(
2102
+ expect10.fail(
1948
2103
  "did not error for get().resolve() on missing actor"
1949
2104
  );
1950
2105
  } catch (err) {
1951
- expect9(err.group).toBe("actor");
1952
- expect9(err.code).toBe("not_found");
2106
+ expect10(err.group).toBe("actor");
2107
+ expect10(err.code).toBe("not_found");
1953
2108
  }
1954
2109
  });
1955
2110
  });
1956
- describe10("Action Functionality", () => {
1957
- test9("should call actions directly on the handle", async (c) => {
2111
+ describe11("Action Functionality", () => {
2112
+ test10("should call actions directly on the handle", async (c) => {
1958
2113
  const { client } = await setupDriverTest(c, driverTestConfig);
1959
2114
  const handle = client.counter.getOrCreate([
1960
2115
  "test-action-handle"
1961
2116
  ]);
1962
2117
  const count1 = await handle.increment(3);
1963
- expect9(count1).toBe(3);
2118
+ expect10(count1).toBe(3);
1964
2119
  const count2 = await handle.increment(5);
1965
- expect9(count2).toBe(8);
2120
+ expect10(count2).toBe(8);
1966
2121
  const retrievedCount = await handle.getCount();
1967
- expect9(retrievedCount).toBe(8);
2122
+ expect10(retrievedCount).toBe(8);
1968
2123
  });
1969
- test9("should handle independent handles to the same actor", async (c) => {
2124
+ test10("should handle independent handles to the same actor", async (c) => {
1970
2125
  const { client } = await setupDriverTest(c, driverTestConfig);
1971
2126
  const handle1 = client.counter.getOrCreate([
1972
2127
  "test-multiple-handles"
@@ -1974,82 +2129,82 @@ function runActorHandleTests(driverTestConfig) {
1974
2129
  const handle2 = client.counter.get(["test-multiple-handles"]);
1975
2130
  await handle1.increment(3);
1976
2131
  const count = await handle2.getCount();
1977
- expect9(count).toBe(3);
2132
+ expect10(count).toBe(3);
1978
2133
  const finalCount = await handle2.increment(4);
1979
- expect9(finalCount).toBe(7);
2134
+ expect10(finalCount).toBe(7);
1980
2135
  const checkCount = await handle1.getCount();
1981
- expect9(checkCount).toBe(7);
2136
+ expect10(checkCount).toBe(7);
1982
2137
  });
1983
- test9("should resolve a actor's ID", async (c) => {
2138
+ test10("should resolve a actor's ID", async (c) => {
1984
2139
  const { client } = await setupDriverTest(c, driverTestConfig);
1985
2140
  const handle = client.counter.getOrCreate(["test-resolve-id"]);
1986
2141
  await handle.increment(1);
1987
2142
  const actorId = await handle.resolve();
1988
- expect9(typeof actorId).toBe("string");
1989
- expect9(actorId).not.toBe("");
2143
+ expect10(typeof actorId).toBe("string");
2144
+ expect10(actorId).not.toBe("");
1990
2145
  const idHandle = client.counter.getForId(actorId);
1991
2146
  const count = await idHandle.getCount();
1992
- expect9(count).toBe(1);
2147
+ expect10(count).toBe(1);
1993
2148
  });
1994
2149
  });
1995
- describe10("Lifecycle Hooks", () => {
1996
- test9("should trigger lifecycle hooks on actor creation", async (c) => {
2150
+ describe11("Lifecycle Hooks", () => {
2151
+ test10("should trigger lifecycle hooks on actor creation", async (c) => {
1997
2152
  const { client } = await setupDriverTest(c, driverTestConfig);
1998
2153
  const handle = client.counterWithLifecycle.getOrCreate([
1999
2154
  "test-lifecycle-handle"
2000
2155
  ]);
2001
2156
  const initialEvents = await handle.getEvents();
2002
- expect9(initialEvents).toContain("onWake");
2157
+ expect10(initialEvents).toContain("onWake");
2003
2158
  const sameHandle = client.counterWithLifecycle.getOrCreate([
2004
2159
  "test-lifecycle-handle"
2005
2160
  ]);
2006
2161
  const events = await sameHandle.getEvents();
2007
- expect9(events).toContain("onWake");
2008
- expect9(events.filter((e) => e === "onWake").length).toBe(1);
2162
+ expect10(events).toContain("onWake");
2163
+ expect10(events.filter((e) => e === "onWake").length).toBe(1);
2009
2164
  });
2010
- test9("should trigger lifecycle hooks for each Action call", async (c) => {
2165
+ test10("should trigger lifecycle hooks for each Action call", async (c) => {
2011
2166
  const { client } = await setupDriverTest(c, driverTestConfig);
2012
2167
  const viewHandle = client.counterWithLifecycle.getOrCreate([
2013
2168
  "test-lifecycle-action"
2014
2169
  ]);
2015
2170
  const initialEvents = await viewHandle.getEvents();
2016
- expect9(initialEvents).toContain("onWake");
2017
- expect9(initialEvents).not.toContain("onBeforeConnect");
2018
- expect9(initialEvents).not.toContain("onConnect");
2019
- expect9(initialEvents).not.toContain("onDisconnect");
2171
+ expect10(initialEvents).toContain("onWake");
2172
+ expect10(initialEvents).not.toContain("onBeforeConnect");
2173
+ expect10(initialEvents).not.toContain("onConnect");
2174
+ expect10(initialEvents).not.toContain("onDisconnect");
2020
2175
  const trackingHandle = client.counterWithLifecycle.getOrCreate(
2021
2176
  ["test-lifecycle-action"],
2022
2177
  { params: { trackLifecycle: true } }
2023
2178
  );
2024
2179
  await trackingHandle.increment(5);
2025
2180
  const eventsAfterAction = await viewHandle.getEvents();
2026
- expect9(eventsAfterAction).toContain("onBeforeConnect");
2027
- expect9(eventsAfterAction).toContain("onConnect");
2028
- expect9(eventsAfterAction).toContain("onDisconnect");
2029
- expect9(
2181
+ expect10(eventsAfterAction).toContain("onBeforeConnect");
2182
+ expect10(eventsAfterAction).toContain("onConnect");
2183
+ expect10(eventsAfterAction).toContain("onDisconnect");
2184
+ expect10(
2030
2185
  eventsAfterAction.filter((e) => e === "onBeforeConnect").length
2031
2186
  ).toBe(1);
2032
- expect9(
2187
+ expect10(
2033
2188
  eventsAfterAction.filter((e) => e === "onConnect").length
2034
2189
  ).toBe(1);
2035
- expect9(
2190
+ expect10(
2036
2191
  eventsAfterAction.filter((e) => e === "onDisconnect").length
2037
2192
  ).toBe(1);
2038
2193
  await trackingHandle.increment(10);
2039
2194
  const eventsAfterSecondAction = await viewHandle.getEvents();
2040
- expect9(
2195
+ expect10(
2041
2196
  eventsAfterSecondAction.filter(
2042
2197
  (e) => e === "onBeforeConnect"
2043
2198
  ).length
2044
2199
  ).toBe(2);
2045
- expect9(
2200
+ expect10(
2046
2201
  eventsAfterSecondAction.filter((e) => e === "onConnect").length
2047
2202
  ).toBe(2);
2048
- expect9(
2203
+ expect10(
2049
2204
  eventsAfterSecondAction.filter((e) => e === "onDisconnect").length
2050
2205
  ).toBe(2);
2051
2206
  });
2052
- test9("should trigger lifecycle hooks for each Action call across multiple handles", async (c) => {
2207
+ test10("should trigger lifecycle hooks for each Action call across multiple handles", async (c) => {
2053
2208
  const { client } = await setupDriverTest(c, driverTestConfig);
2054
2209
  const viewHandle = client.counterWithLifecycle.getOrCreate([
2055
2210
  "test-lifecycle-multi-handle"
@@ -2065,12 +2220,12 @@ function runActorHandleTests(driverTestConfig) {
2065
2220
  await trackingHandle1.increment(5);
2066
2221
  await trackingHandle2.increment(10);
2067
2222
  const events = await viewHandle.getEvents();
2068
- expect9(events.filter((e) => e === "onWake").length).toBe(1);
2069
- expect9(
2223
+ expect10(events.filter((e) => e === "onWake").length).toBe(1);
2224
+ expect10(
2070
2225
  events.filter((e) => e === "onBeforeConnect").length
2071
2226
  ).toBe(2);
2072
- expect9(events.filter((e) => e === "onConnect").length).toBe(2);
2073
- expect9(events.filter((e) => e === "onDisconnect").length).toBe(
2227
+ expect10(events.filter((e) => e === "onConnect").length).toBe(2);
2228
+ expect10(events.filter((e) => e === "onDisconnect").length).toBe(
2074
2229
  2
2075
2230
  );
2076
2231
  });
@@ -2078,159 +2233,6 @@ function runActorHandleTests(driverTestConfig) {
2078
2233
  });
2079
2234
  }
2080
2235
 
2081
- // src/driver-test-suite/tests/actor-conn-hibernation.ts
2082
- import { describe as describe11, expect as expect10, test as test10, vi as vi5 } from "vitest";
2083
-
2084
- // fixtures/driver-test-suite/hibernation.ts
2085
- var HIBERNATION_SLEEP_TIMEOUT = 500;
2086
- var hibernationActor = actor({
2087
- state: {
2088
- sleepCount: 0,
2089
- wakeCount: 0
2090
- },
2091
- createConnState: (c) => {
2092
- return {
2093
- count: 0,
2094
- connectCount: 0,
2095
- disconnectCount: 0
2096
- };
2097
- },
2098
- onWake: (c) => {
2099
- c.state.wakeCount += 1;
2100
- },
2101
- onSleep: (c) => {
2102
- c.state.sleepCount += 1;
2103
- },
2104
- onConnect: (c, conn) => {
2105
- conn.state.connectCount += 1;
2106
- },
2107
- onDisconnect: (c, conn) => {
2108
- conn.state.disconnectCount += 1;
2109
- },
2110
- actions: {
2111
- // Basic RPC that returns a simple value
2112
- ping: (c) => {
2113
- return "pong";
2114
- },
2115
- // Increment the connection's count
2116
- connIncrement: (c) => {
2117
- c.conn.state.count += 1;
2118
- return c.conn.state.count;
2119
- },
2120
- // Get the connection's count
2121
- getConnCount: (c) => {
2122
- return c.conn.state.count;
2123
- },
2124
- // Get the connection's lifecycle counts
2125
- getConnLifecycleCounts: (c) => {
2126
- return {
2127
- connectCount: c.conn.state.connectCount,
2128
- disconnectCount: c.conn.state.disconnectCount
2129
- };
2130
- },
2131
- // Get all connection IDs
2132
- getConnectionIds: (c) => {
2133
- return c.conns.entries().map((x) => x[0]).toArray();
2134
- },
2135
- // Get actor sleep/wake counts
2136
- getActorCounts: (c) => {
2137
- return {
2138
- sleepCount: c.state.sleepCount,
2139
- wakeCount: c.state.wakeCount
2140
- };
2141
- },
2142
- // Trigger sleep
2143
- triggerSleep: (c) => {
2144
- c.sleep();
2145
- }
2146
- },
2147
- options: {
2148
- sleepTimeout: HIBERNATION_SLEEP_TIMEOUT
2149
- }
2150
- });
2151
-
2152
- // src/driver-test-suite/tests/actor-conn-hibernation.ts
2153
- function runActorConnHibernationTests(driverTestConfig) {
2154
- var _a;
2155
- describe11.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.hibernation)(
2156
- "Connection Hibernation",
2157
- () => {
2158
- test10("basic conn hibernation", async (c) => {
2159
- const { client } = await setupDriverTest(c, driverTestConfig);
2160
- const hibernatingActor = client.hibernationActor.getOrCreate().connect();
2161
- const ping1 = await hibernatingActor.ping();
2162
- expect10(ping1).toBe("pong");
2163
- await hibernatingActor.triggerSleep();
2164
- await waitFor(
2165
- driverTestConfig,
2166
- HIBERNATION_SLEEP_TIMEOUT + 100
2167
- );
2168
- const ping2 = await hibernatingActor.ping();
2169
- expect10(ping2).toBe("pong");
2170
- await hibernatingActor.dispose();
2171
- });
2172
- test10("conn state persists through hibernation", async (c) => {
2173
- const { client } = await setupDriverTest(c, driverTestConfig);
2174
- const hibernatingActor = client.hibernationActor.getOrCreate().connect();
2175
- const count1 = await hibernatingActor.connIncrement();
2176
- expect10(count1).toBe(1);
2177
- const count2 = await hibernatingActor.connIncrement();
2178
- expect10(count2).toBe(2);
2179
- const initialLifecycle = await hibernatingActor.getConnLifecycleCounts();
2180
- expect10(initialLifecycle.connectCount).toBe(1);
2181
- expect10(initialLifecycle.disconnectCount).toBe(0);
2182
- const initialActorCounts = await hibernatingActor.getActorCounts();
2183
- expect10(initialActorCounts.wakeCount).toBe(1);
2184
- expect10(initialActorCounts.sleepCount).toBe(0);
2185
- await hibernatingActor.triggerSleep();
2186
- await waitFor(
2187
- driverTestConfig,
2188
- HIBERNATION_SLEEP_TIMEOUT + 100
2189
- );
2190
- const count3 = await hibernatingActor.getConnCount();
2191
- expect10(count3).toBe(2);
2192
- const finalLifecycle = await hibernatingActor.getConnLifecycleCounts();
2193
- expect10(finalLifecycle.connectCount).toBe(1);
2194
- expect10(finalLifecycle.disconnectCount).toBe(0);
2195
- const finalActorCounts = await hibernatingActor.getActorCounts();
2196
- expect10(finalActorCounts.wakeCount).toBe(2);
2197
- expect10(finalActorCounts.sleepCount).toBe(1);
2198
- await hibernatingActor.dispose();
2199
- });
2200
- test10("closing connection during hibernation", async (c) => {
2201
- const { client } = await setupDriverTest(c, driverTestConfig);
2202
- const conn1 = client.hibernationActor.getOrCreate().connect();
2203
- await conn1.ping();
2204
- const connectionIds = await conn1.getConnectionIds();
2205
- expect10(connectionIds.length).toBe(1);
2206
- const conn1Id = connectionIds[0];
2207
- await conn1.triggerSleep();
2208
- await waitFor(
2209
- driverTestConfig,
2210
- HIBERNATION_SLEEP_TIMEOUT + 100
2211
- );
2212
- await conn1.dispose();
2213
- await waitFor(driverTestConfig, 250);
2214
- const conn2 = client.hibernationActor.getOrCreate().connect();
2215
- await vi5.waitFor(
2216
- async () => {
2217
- const newConnectionIds = await conn2.getConnectionIds();
2218
- expect10(newConnectionIds.length).toBe(1);
2219
- expect10(newConnectionIds[0]).not.toBe(conn1Id);
2220
- },
2221
- {
2222
- timeout: 5e3,
2223
- interval: 100
2224
- }
2225
- );
2226
- const lifecycle = await conn2.getConnLifecycleCounts();
2227
- expect10(lifecycle.disconnectCount).toBe(0);
2228
- await conn2.dispose();
2229
- });
2230
- }
2231
- );
2232
- }
2233
-
2234
2236
  // src/driver-test-suite/tests/actor-inline-client.ts
2235
2237
  import { describe as describe12, expect as expect11, test as test11 } from "vitest";
2236
2238
  function runActorInlineClientTests(driverTestConfig) {