rivetkit 2.0.6 → 2.0.7-rc.1

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 (170) hide show
  1. package/dist/schemas/actor-persist/v1.ts +0 -6
  2. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.cts +28 -0
  3. package/dist/tsup/actor-router-consts-B3Lu87yJ.d.ts +28 -0
  4. package/dist/tsup/{chunk-MRRT2CZD.cjs → chunk-3MBP4WNC.cjs} +7 -7
  5. package/dist/tsup/{chunk-MRRT2CZD.cjs.map → chunk-3MBP4WNC.cjs.map} +1 -1
  6. package/dist/tsup/{chunk-TWGATZ3X.cjs → chunk-3Y45CIF4.cjs} +922 -872
  7. package/dist/tsup/chunk-3Y45CIF4.cjs.map +1 -0
  8. package/dist/tsup/chunk-4GP7BZSR.js +102 -0
  9. package/dist/tsup/chunk-4GP7BZSR.js.map +1 -0
  10. package/dist/tsup/{chunk-UFWAK3X2.cjs → chunk-5ZOHIKWG.cjs} +660 -385
  11. package/dist/tsup/chunk-5ZOHIKWG.cjs.map +1 -0
  12. package/dist/tsup/{chunk-5JBFVV4C.cjs → chunk-6EUWRXLT.cjs} +21 -7
  13. package/dist/tsup/chunk-6EUWRXLT.cjs.map +1 -0
  14. package/dist/tsup/{chunk-UTI5NCES.cjs → chunk-6OVKCDSH.cjs} +6 -6
  15. package/dist/tsup/{chunk-UTI5NCES.cjs.map → chunk-6OVKCDSH.cjs.map} +1 -1
  16. package/dist/tsup/{chunk-VPV4MWXR.js → chunk-7N56ZUC7.js} +3 -3
  17. package/dist/tsup/{chunk-DIAYNQTE.cjs → chunk-B3TLRM4Q.cjs} +12 -12
  18. package/dist/tsup/{chunk-DIAYNQTE.cjs.map → chunk-B3TLRM4Q.cjs.map} +1 -1
  19. package/dist/tsup/{chunk-4CKHQRXG.js → chunk-BW5DPM6Z.js} +515 -240
  20. package/dist/tsup/chunk-BW5DPM6Z.js.map +1 -0
  21. package/dist/tsup/{chunk-NTCUGYSD.cjs → chunk-DFS77KAA.cjs} +34 -31
  22. package/dist/tsup/chunk-DFS77KAA.cjs.map +1 -0
  23. package/dist/tsup/{chunk-VCEHU56K.js → chunk-E4UVJKSV.js} +2 -2
  24. package/dist/tsup/chunk-G4ABMAQY.cjs +102 -0
  25. package/dist/tsup/chunk-G4ABMAQY.cjs.map +1 -0
  26. package/dist/tsup/{chunk-ZYLTS2EM.js → chunk-GZVBFXBI.js} +2 -2
  27. package/dist/tsup/{chunk-W6LN7AF5.js → chunk-HPT3I7UU.js} +866 -816
  28. package/dist/tsup/chunk-HPT3I7UU.js.map +1 -0
  29. package/dist/tsup/{chunk-7OUKNSTU.js → chunk-JD54PXWP.js} +17 -14
  30. package/dist/tsup/chunk-JD54PXWP.js.map +1 -0
  31. package/dist/tsup/{chunk-KG3C7MKR.cjs → chunk-K4ENQCC4.cjs} +3 -3
  32. package/dist/tsup/{chunk-KG3C7MKR.cjs.map → chunk-K4ENQCC4.cjs.map} +1 -1
  33. package/dist/tsup/{chunk-WC2PSJWN.js → chunk-PUSQNDJG.js} +2 -2
  34. package/dist/tsup/{chunk-RGQR2J7S.js → chunk-RVP5RUSC.js} +20 -6
  35. package/dist/tsup/chunk-RVP5RUSC.js.map +1 -0
  36. package/dist/tsup/{chunk-TCUI5JFE.cjs → chunk-SAZCNSVY.cjs} +45 -18
  37. package/dist/tsup/chunk-SAZCNSVY.cjs.map +1 -0
  38. package/dist/tsup/{chunk-G75SVQON.js → chunk-SBKRVQS2.js} +9 -5
  39. package/dist/tsup/chunk-SBKRVQS2.js.map +1 -0
  40. package/dist/tsup/{chunk-6P6RA47N.cjs → chunk-TZGUSEIJ.cjs} +14 -10
  41. package/dist/tsup/chunk-TZGUSEIJ.cjs.map +1 -0
  42. package/dist/tsup/{chunk-2K3JMDAN.js → chunk-YQ4XQYPM.js} +40 -13
  43. package/dist/tsup/chunk-YQ4XQYPM.js.map +1 -0
  44. package/dist/tsup/client/mod.cjs +9 -9
  45. package/dist/tsup/client/mod.d.cts +7 -8
  46. package/dist/tsup/client/mod.d.ts +7 -8
  47. package/dist/tsup/client/mod.js +8 -8
  48. package/dist/tsup/common/log.cjs +3 -3
  49. package/dist/tsup/common/log.js +2 -2
  50. package/dist/tsup/common/websocket.cjs +4 -4
  51. package/dist/tsup/common/websocket.js +3 -3
  52. package/dist/tsup/{connection-BLemxi4f.d.ts → conn-DCSQgIlw.d.ts} +1605 -1353
  53. package/dist/tsup/{connection-CpDIydXf.d.cts → conn-DdzHTm2E.d.cts} +1605 -1353
  54. package/dist/tsup/driver-helpers/mod.cjs +31 -5
  55. package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
  56. package/dist/tsup/driver-helpers/mod.d.cts +7 -8
  57. package/dist/tsup/driver-helpers/mod.d.ts +7 -8
  58. package/dist/tsup/driver-helpers/mod.js +33 -7
  59. package/dist/tsup/driver-test-suite/mod.cjs +317 -222
  60. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  61. package/dist/tsup/driver-test-suite/mod.d.cts +7 -7
  62. package/dist/tsup/driver-test-suite/mod.d.ts +7 -7
  63. package/dist/tsup/driver-test-suite/mod.js +582 -487
  64. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  65. package/dist/tsup/inspector/mod.cjs +16 -6
  66. package/dist/tsup/inspector/mod.cjs.map +1 -1
  67. package/dist/tsup/inspector/mod.d.cts +34 -7
  68. package/dist/tsup/inspector/mod.d.ts +34 -7
  69. package/dist/tsup/inspector/mod.js +17 -7
  70. package/dist/tsup/mod.cjs +10 -20
  71. package/dist/tsup/mod.cjs.map +1 -1
  72. package/dist/tsup/mod.d.cts +9 -7
  73. package/dist/tsup/mod.d.ts +9 -7
  74. package/dist/tsup/mod.js +9 -19
  75. package/dist/tsup/test/mod.cjs +11 -11
  76. package/dist/tsup/test/mod.d.cts +6 -7
  77. package/dist/tsup/test/mod.d.ts +6 -7
  78. package/dist/tsup/test/mod.js +10 -10
  79. package/dist/tsup/utils.cjs +4 -2
  80. package/dist/tsup/utils.cjs.map +1 -1
  81. package/dist/tsup/utils.d.cts +11 -1
  82. package/dist/tsup/utils.d.ts +11 -1
  83. package/dist/tsup/utils.js +3 -1
  84. package/package.json +8 -4
  85. package/src/actor/action.ts +1 -1
  86. package/src/actor/config.ts +1 -1
  87. package/src/actor/conn-drivers.ts +205 -0
  88. package/src/actor/conn-socket.ts +6 -0
  89. package/src/actor/{connection.ts → conn.ts} +78 -84
  90. package/src/actor/context.ts +1 -1
  91. package/src/actor/driver.ts +4 -43
  92. package/src/actor/instance.ts +162 -86
  93. package/src/actor/mod.ts +1 -11
  94. package/src/actor/persisted.ts +2 -5
  95. package/src/actor/protocol/old.ts +1 -1
  96. package/src/actor/router-endpoints.ts +142 -106
  97. package/src/actor/router.ts +81 -45
  98. package/src/actor/utils.ts +5 -1
  99. package/src/client/actor-conn.ts +154 -23
  100. package/src/client/client.ts +1 -1
  101. package/src/client/config.ts +7 -0
  102. package/src/common/actor-router-consts.ts +29 -8
  103. package/src/common/router.ts +2 -1
  104. package/src/common/versioned-data.ts +5 -5
  105. package/src/driver-helpers/mod.ts +14 -1
  106. package/src/driver-test-suite/mod.ts +11 -2
  107. package/src/driver-test-suite/test-inline-client-driver.ts +36 -18
  108. package/src/driver-test-suite/tests/actor-conn-state.ts +66 -22
  109. package/src/driver-test-suite/tests/actor-conn.ts +65 -126
  110. package/src/driver-test-suite/tests/actor-reconnect.ts +160 -0
  111. package/src/driver-test-suite/tests/actor-sleep.ts +0 -1
  112. package/src/driver-test-suite/tests/raw-websocket.ts +0 -35
  113. package/src/driver-test-suite/utils.ts +3 -3
  114. package/src/drivers/default.ts +8 -7
  115. package/src/drivers/engine/actor-driver.ts +53 -31
  116. package/src/drivers/engine/config.ts +4 -0
  117. package/src/drivers/file-system/actor.ts +0 -6
  118. package/src/drivers/file-system/global-state.ts +3 -14
  119. package/src/drivers/file-system/manager.ts +12 -8
  120. package/src/inspector/actor.ts +4 -3
  121. package/src/inspector/config.ts +10 -1
  122. package/src/inspector/mod.ts +1 -0
  123. package/src/inspector/utils.ts +23 -4
  124. package/src/manager/driver.ts +11 -1
  125. package/src/manager/gateway.ts +407 -0
  126. package/src/manager/router.ts +269 -468
  127. package/src/manager-api/actors.ts +61 -0
  128. package/src/manager-api/common.ts +4 -0
  129. package/src/mod.ts +1 -1
  130. package/src/registry/mod.ts +119 -10
  131. package/src/remote-manager-driver/actor-http-client.ts +30 -19
  132. package/src/remote-manager-driver/actor-websocket-client.ts +43 -16
  133. package/src/remote-manager-driver/api-endpoints.ts +19 -21
  134. package/src/remote-manager-driver/api-utils.ts +10 -1
  135. package/src/remote-manager-driver/mod.ts +51 -48
  136. package/src/remote-manager-driver/ws-proxy.ts +2 -9
  137. package/src/test/mod.ts +6 -2
  138. package/src/utils.ts +21 -2
  139. package/dist/tsup/actor-router-consts-BK6arfy8.d.cts +0 -17
  140. package/dist/tsup/actor-router-consts-BK6arfy8.d.ts +0 -17
  141. package/dist/tsup/chunk-2K3JMDAN.js.map +0 -1
  142. package/dist/tsup/chunk-42I3OZ3Q.js +0 -15
  143. package/dist/tsup/chunk-42I3OZ3Q.js.map +0 -1
  144. package/dist/tsup/chunk-4CKHQRXG.js.map +0 -1
  145. package/dist/tsup/chunk-5JBFVV4C.cjs.map +0 -1
  146. package/dist/tsup/chunk-6P6RA47N.cjs.map +0 -1
  147. package/dist/tsup/chunk-7OUKNSTU.js.map +0 -1
  148. package/dist/tsup/chunk-G75SVQON.js.map +0 -1
  149. package/dist/tsup/chunk-KUPQZYUQ.cjs +0 -15
  150. package/dist/tsup/chunk-KUPQZYUQ.cjs.map +0 -1
  151. package/dist/tsup/chunk-NTCUGYSD.cjs.map +0 -1
  152. package/dist/tsup/chunk-RGQR2J7S.js.map +0 -1
  153. package/dist/tsup/chunk-TCUI5JFE.cjs.map +0 -1
  154. package/dist/tsup/chunk-TWGATZ3X.cjs.map +0 -1
  155. package/dist/tsup/chunk-UFWAK3X2.cjs.map +0 -1
  156. package/dist/tsup/chunk-W6LN7AF5.js.map +0 -1
  157. package/dist/tsup/common-CXCe7s6i.d.cts +0 -218
  158. package/dist/tsup/common-CXCe7s6i.d.ts +0 -218
  159. package/src/actor/generic-conn-driver.ts +0 -246
  160. package/src/common/fake-event-source.ts +0 -267
  161. package/src/manager-api/routes/actors-create.ts +0 -16
  162. package/src/manager-api/routes/actors-delete.ts +0 -4
  163. package/src/manager-api/routes/actors-get-by-id.ts +0 -7
  164. package/src/manager-api/routes/actors-get-or-create-by-id.ts +0 -29
  165. package/src/manager-api/routes/actors-get.ts +0 -7
  166. package/src/manager-api/routes/common.ts +0 -18
  167. /package/dist/tsup/{chunk-VPV4MWXR.js.map → chunk-7N56ZUC7.js.map} +0 -0
  168. /package/dist/tsup/{chunk-VCEHU56K.js.map → chunk-E4UVJKSV.js.map} +0 -0
  169. /package/dist/tsup/{chunk-ZYLTS2EM.js.map → chunk-GZVBFXBI.js.map} +0 -0
  170. /package/dist/tsup/{chunk-WC2PSJWN.js.map → chunk-PUSQNDJG.js.map} +0 -0
@@ -1,37 +1,46 @@
1
1
  import {
2
2
  getPort
3
- } from "../chunk-G75SVQON.js";
3
+ } from "../chunk-SBKRVQS2.js";
4
4
  import {
5
5
  actor,
6
6
  createManagerRouter
7
- } from "../chunk-W6LN7AF5.js";
7
+ } from "../chunk-HPT3I7UU.js";
8
8
  import {
9
+ configureInspectorAccessToken,
9
10
  createActorInspectorClient,
10
11
  createManagerInspectorClient
11
- } from "../chunk-42I3OZ3Q.js";
12
+ } from "../chunk-4GP7BZSR.js";
12
13
  import {
13
14
  createClient
14
- } from "../chunk-VPV4MWXR.js";
15
+ } from "../chunk-7N56ZUC7.js";
15
16
  import {
16
17
  ActorError,
17
18
  createClientWithDriver
18
- } from "../chunk-4CKHQRXG.js";
19
- import "../chunk-ZYLTS2EM.js";
19
+ } from "../chunk-BW5DPM6Z.js";
20
+ import "../chunk-GZVBFXBI.js";
20
21
  import {
21
22
  importWebSocket
22
- } from "../chunk-VCEHU56K.js";
23
+ } from "../chunk-E4UVJKSV.js";
23
24
  import {
24
25
  RunConfigSchema
25
- } from "../chunk-7OUKNSTU.js";
26
+ } from "../chunk-JD54PXWP.js";
26
27
  import {
27
28
  HEADER_ACTOR_ID,
28
29
  HEADER_ACTOR_QUERY,
30
+ WS_PROTOCOL_ACTOR,
31
+ WS_PROTOCOL_CONN_PARAMS,
32
+ WS_PROTOCOL_ENCODING,
33
+ WS_PROTOCOL_PATH,
34
+ WS_PROTOCOL_TARGET,
35
+ WS_PROTOCOL_TRANSPORT,
29
36
  assertUnreachable
30
- } from "../chunk-2K3JMDAN.js";
37
+ } from "../chunk-YQ4XQYPM.js";
31
38
  import {
32
39
  getLogger
33
- } from "../chunk-WC2PSJWN.js";
34
- import "../chunk-RGQR2J7S.js";
40
+ } from "../chunk-PUSQNDJG.js";
41
+ import {
42
+ promiseWithResolvers
43
+ } from "../chunk-RVP5RUSC.js";
35
44
  import {
36
45
  INTERNAL_ERROR_CODE,
37
46
  INTERNAL_ERROR_DESCRIPTION
@@ -41,8 +50,8 @@ import {
41
50
  import { serve as honoServe } from "@hono/node-server";
42
51
  import { createNodeWebSocket } from "@hono/node-ws";
43
52
  import { bundleRequire } from "bundle-require";
44
- import invariant2 from "invariant";
45
- import { describe as describe20 } from "vitest";
53
+ import invariant from "invariant";
54
+ import { describe as describe21 } from "vitest";
46
55
 
47
56
  // src/driver-test-suite/log.ts
48
57
  function logger() {
@@ -53,7 +62,6 @@ function logger() {
53
62
  import { describe, expect, test } from "vitest";
54
63
 
55
64
  // src/driver-test-suite/utils.ts
56
- import invariant from "invariant";
57
65
  import { vi } from "vitest";
58
66
 
59
67
  // src/driver-test-suite/test-inline-client-driver.ts
@@ -104,7 +112,8 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
104
112
  method: actorRequest.method,
105
113
  headers,
106
114
  body: actorRequest.body,
107
- signal: actorRequest.signal
115
+ signal: actorRequest.signal,
116
+ duplex: "half"
108
117
  })
109
118
  );
110
119
  if (!response.ok && ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json"))) {
@@ -129,38 +138,46 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
129
138
  }
130
139
  return response;
131
140
  },
132
- async openWebSocket(path, actorId, encoding2, params) {
141
+ async openWebSocket(path, actorId, encoding2, params, connId, connToken) {
133
142
  const WebSocket2 = await importWebSocket();
134
143
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
135
- logger().debug({
136
- msg: "creating websocket connection via test inline driver"
137
- });
138
144
  const wsUrl = new URL(
139
145
  `${endpoint}/.test/inline-driver/connect-websocket/ws`
140
146
  );
141
- wsUrl.searchParams.set("path", normalizedPath);
142
- wsUrl.searchParams.set("actorId", actorId);
143
- if (params !== void 0)
144
- wsUrl.searchParams.set("params", JSON.stringify(params));
145
- wsUrl.searchParams.set("encodingKind", encoding2);
147
+ logger().debug({
148
+ msg: "creating websocket connection via test inline driver",
149
+ url: wsUrl.toString()
150
+ });
146
151
  const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
147
- const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}${wsUrl.search}`;
152
+ const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}`;
148
153
  logger().debug({ msg: "connecting to websocket", url: finalWsUrl });
149
- const ws = new WebSocket2(finalWsUrl, [
150
- // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
151
- "rivetkit"
152
- ]);
154
+ const protocols = [];
155
+ protocols.push(`${WS_PROTOCOL_TARGET}actor`);
156
+ protocols.push(`${WS_PROTOCOL_ACTOR}${actorId}`);
157
+ protocols.push(`${WS_PROTOCOL_ENCODING}${encoding2}`);
158
+ protocols.push(`${WS_PROTOCOL_TRANSPORT}${transport}`);
159
+ protocols.push(
160
+ `${WS_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
161
+ );
162
+ if (params !== void 0) {
163
+ protocols.push(
164
+ `${WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
165
+ );
166
+ }
167
+ const ws = new WebSocket2(finalWsUrl, protocols);
153
168
  return ws;
154
169
  },
155
170
  async proxyRequest(c, actorRequest, actorId) {
156
171
  return await this.sendRequest(actorId, actorRequest);
157
172
  },
158
- proxyWebSocket(_c, _path, _actorId, _encoding, _params, _authData) {
173
+ proxyWebSocket(_c, _path, _actorId, _encoding, _params) {
159
174
  throw "UNIMPLEMENTED";
160
175
  },
161
176
  displayInformation() {
162
177
  return { name: "Test Inline", properties: {} };
163
- }
178
+ },
179
+ // TODO:
180
+ getOrCreateInspectorAccessToken: () => ""
164
181
  // action: async <Args extends Array<unknown> = unknown[], Response = unknown>(
165
182
  // _c: HonoContext | undefined,
166
183
  // actorQuery: ActorQuery,
@@ -496,7 +513,8 @@ async function makeInlineRequest(endpoint, encoding, transport, method, args) {
496
513
  transport,
497
514
  method,
498
515
  args
499
- })
516
+ }),
517
+ duplex: "half"
500
518
  });
501
519
  if (!response.ok) {
502
520
  throw new Error(`Failed to call inline ${method}: ${response.statusText}`);
@@ -537,14 +555,14 @@ async function setupDriverTest(c, driverTestConfig) {
537
555
  transport: driverTestConfig.transport
538
556
  });
539
557
  } else if (driverTestConfig.clientType === "inline") {
558
+ const transport = driverTestConfig.transport ?? "websocket";
540
559
  const managerDriver = createTestInlineClientDriver(
541
560
  endpoint,
542
561
  "bare",
543
- driverTestConfig.transport ?? "websocket"
562
+ transport
544
563
  );
545
- invariant(driverTestConfig.transport, "missing transport");
546
564
  const runConfig = RunConfigSchema.parse({
547
- transport: driverTestConfig.transport
565
+ transport
548
566
  });
549
567
  client = createClientWithDriver(managerDriver, runConfig);
550
568
  } else {
@@ -649,7 +667,7 @@ function runActionFeaturesTests(driverTestConfig) {
649
667
  }
650
668
 
651
669
  // src/driver-test-suite/tests/actor-conn.ts
652
- import { describe as describe2, expect as expect2, test as test2 } from "vitest";
670
+ import { describe as describe2, expect as expect2, test as test2, vi as vi2 } from "vitest";
653
671
  function runActorConnTests(driverTestConfig) {
654
672
  describe2("Actor Connection Tests", () => {
655
673
  describe2("Connection Methods", () => {
@@ -696,17 +714,19 @@ function runActorConnTests(driverTestConfig) {
696
714
  const handle = client.counter.getOrCreate(["test-mixed-rpc-ws"]);
697
715
  const connection = handle.connect();
698
716
  const receivedEvents = [];
699
- const receivedEventsPromise = new Promise((resolve) => {
700
- connection.on("newCount", (count) => {
701
- receivedEvents.push(count);
702
- if (receivedEvents.includes(1) && receivedEvents.includes(6) && receivedEvents.includes(9))
703
- resolve(void 0);
704
- });
717
+ connection.on("newCount", (count) => {
718
+ receivedEvents.push(count);
719
+ });
720
+ await vi2.waitFor(async () => {
721
+ await connection.setCount(1);
722
+ expect2(receivedEvents).includes(1);
723
+ });
724
+ await handle.setCount(2);
725
+ await handle.setCount(3);
726
+ await vi2.waitFor(() => {
727
+ expect2(receivedEvents).includes(2);
728
+ expect2(receivedEvents).includes(3);
705
729
  });
706
- await connection.increment(1);
707
- await handle.increment(5);
708
- await handle.increment(3);
709
- await receivedEventsPromise;
710
730
  await connection.dispose();
711
731
  });
712
732
  test2("should receive events via broadcast", async (c) => {
@@ -717,10 +737,15 @@ function runActorConnTests(driverTestConfig) {
717
737
  connection.on("newCount", (count) => {
718
738
  receivedEvents.push(count);
719
739
  });
720
- await connection.increment(5);
721
- await connection.increment(3);
722
- expect2(receivedEvents).toContain(5);
723
- expect2(receivedEvents).toContain(8);
740
+ await vi2.waitFor(
741
+ async () => {
742
+ await connection.setCount(5);
743
+ await connection.setCount(8);
744
+ expect2(receivedEvents).toContain(5);
745
+ expect2(receivedEvents).toContain(8);
746
+ },
747
+ { timeout: 1e4 }
748
+ );
724
749
  await connection.dispose();
725
750
  });
726
751
  test2("should handle one-time events with once()", async (c) => {
@@ -733,8 +758,10 @@ function runActorConnTests(driverTestConfig) {
733
758
  });
734
759
  await connection.increment(5);
735
760
  await connection.increment(3);
736
- expect2(receivedEvents).toEqual([5]);
737
- expect2(receivedEvents).not.toContain(8);
761
+ await vi2.waitFor(() => {
762
+ expect2(receivedEvents).toEqual([5]);
763
+ expect2(receivedEvents).not.toContain(8);
764
+ });
738
765
  await connection.dispose();
739
766
  });
740
767
  test2("should unsubscribe from events", async (c) => {
@@ -745,10 +772,12 @@ function runActorConnTests(driverTestConfig) {
745
772
  const unsubscribe = connection.on("newCount", (count) => {
746
773
  receivedEvents.push(count);
747
774
  });
748
- await connection.increment(5);
775
+ await vi2.waitFor(async () => {
776
+ await connection.setCount(5);
777
+ expect2(receivedEvents).toEqual([5]);
778
+ });
749
779
  unsubscribe();
750
- await connection.increment(3);
751
- expect2(receivedEvents).toEqual([5]);
780
+ await connection.setCount(8);
752
781
  expect2(receivedEvents).not.toContain(8);
753
782
  await connection.dispose();
754
783
  });
@@ -774,7 +803,9 @@ function runActorConnTests(driverTestConfig) {
774
803
  });
775
804
  });
776
805
  describe2("Lifecycle Hooks", () => {
777
- test2("should trigger lifecycle hooks", async (c) => {
806
+ test2.skipIf(
807
+ driverTestConfig.transport === "sse" && driverTestConfig.clientType === "inline"
808
+ )("should trigger lifecycle hooks", async (c) => {
778
809
  const { client } = await setupDriverTest(c, driverTestConfig);
779
810
  const connHandle = client.counterWithLifecycle.getOrCreate(
780
811
  ["test-lifecycle"],
@@ -786,81 +817,30 @@ function runActorConnTests(driverTestConfig) {
786
817
  const events = await connection.getEvents();
787
818
  expect2(events).toEqual(["onStart", "onBeforeConnect", "onConnect"]);
788
819
  await connection.dispose();
789
- const handle = client.counterWithLifecycle.getOrCreate([
790
- "test-lifecycle"
791
- ]);
792
- const finalEvents = await handle.getEvents();
793
- expect2(finalEvents).toBeOneOf([
794
- // Still active
795
- ["onStart", "onBeforeConnect", "onConnect", "onDisconnect"],
796
- // Went to sleep and woke back up
797
- [
798
- "onStart",
799
- "onBeforeConnect",
800
- "onConnect",
801
- "onDisconnect",
802
- "onStart"
803
- ]
804
- ]);
805
- });
806
- });
807
- describe2("Connection Liveness", () => {
808
- test2.skip("should return correct liveness status for connections", async (c) => {
809
- const { client } = await setupDriverTest(c, driverTestConfig);
810
- const handle = client.connLivenessActor.getOrCreate([
811
- "test-liveness-status"
812
- ]);
813
- const connA = handle.connect();
814
- const connB = handle.connect();
815
- const connAId = await connA.getConnectionId();
816
- const connBId = await connB.getConnectionId();
817
- await connA.increment(5);
818
- await connB.increment(5);
819
- const counter = await handle.getCounter();
820
- expect2(counter).toBe(10);
821
- const connectionsStatusBeforeKill = await handle.getWsConnectionsLiveness();
822
- expect2(connectionsStatusBeforeKill).toHaveLength(2);
823
- expect2(connectionsStatusBeforeKill).toContainEqual(
824
- expect2.objectContaining({
825
- id: connAId,
826
- status: "connected",
827
- lastSeen: FAKE_TIME.getTime()
828
- })
829
- );
830
- expect2(connectionsStatusBeforeKill).toContainEqual(
831
- expect2.objectContaining({
832
- id: connBId,
833
- status: "connected",
834
- lastSeen: FAKE_TIME.getTime()
835
- })
836
- );
837
- await handle.kill(connAId);
838
- const connectionsStatusAfterKill = await handle.getWsConnectionsLiveness();
839
- expect2(connectionsStatusAfterKill).toEqual(
840
- expect2.arrayContaining([
841
- expect2.objectContaining({
842
- id: connAId,
843
- status: "reconnecting",
844
- lastSeen: FAKE_TIME.getTime()
845
- }),
846
- expect2.objectContaining({
847
- id: connBId,
848
- status: "connected",
849
- lastSeen: FAKE_TIME.getTime()
850
- })
851
- ])
852
- );
853
- await waitFor(driverTestConfig, 5e3);
854
- const connectionsStatusAfterCleanup = await handle.getWsConnectionsLiveness();
855
- expect2(connectionsStatusAfterCleanup).not.toContainEqual(
856
- expect2.objectContaining({
857
- id: connAId
858
- })
859
- );
860
- expect2(connectionsStatusAfterCleanup).toContainEqual(
861
- expect2.objectContaining({
862
- id: connBId
863
- })
820
+ await vi2.waitFor(
821
+ async () => {
822
+ const handle = client.counterWithLifecycle.getOrCreate([
823
+ "test-lifecycle"
824
+ ]);
825
+ const finalEvents = await handle.getEvents();
826
+ expect2(finalEvents).toBeOneOf([
827
+ // Still active
828
+ ["onStart", "onBeforeConnect", "onConnect", "onDisconnect"],
829
+ // Went to sleep and woke back up
830
+ [
831
+ "onStart",
832
+ "onBeforeConnect",
833
+ "onConnect",
834
+ "onDisconnect",
835
+ "onStart"
836
+ ]
837
+ ]);
838
+ },
839
+ // NOTE: High timeout required for Cloudflare Workers
840
+ {
841
+ timeout: 1e4,
842
+ interval: 100
843
+ }
864
844
  );
865
845
  });
866
846
  });
@@ -868,7 +848,7 @@ function runActorConnTests(driverTestConfig) {
868
848
  }
869
849
 
870
850
  // src/driver-test-suite/tests/actor-conn-state.ts
871
- import { describe as describe3, expect as expect3, test as test3, vi as vi2 } from "vitest";
851
+ import { describe as describe3, expect as expect3, test as test3, vi as vi3 } from "vitest";
872
852
  function runActorConnStateTests(driverTestConfig) {
873
853
  describe3("Actor Connection State Tests", () => {
874
854
  describe3("Connection State Initialization", () => {
@@ -948,21 +928,57 @@ function runActorConnStateTests(driverTestConfig) {
948
928
  });
949
929
  });
950
930
  describe3("Connection Lifecycle", () => {
951
- test3("should track connection and disconnection events", async (c) => {
931
+ test3.skipIf(
932
+ driverTestConfig.transport === "sse" && driverTestConfig.clientType === "inline"
933
+ )("should track connection and disconnection events", async (c) => {
952
934
  const { client } = await setupDriverTest(c, driverTestConfig);
953
- const handle = client.connStateActor.getOrCreate();
954
- const conn = handle.connect();
935
+ const debugHandle = client.connStateActor.getOrCreate(void 0, {
936
+ params: { noCount: true }
937
+ });
938
+ const conn = client.connStateActor.getOrCreate().connect();
955
939
  const connState = await conn.getConnectionState();
956
- const connectionIds = await conn.getConnectionIds();
957
- expect3(connectionIds).toContain(connState.id);
958
- const initialDisconnections = await conn.getDisconnectionCount();
940
+ await vi3.waitFor(async () => {
941
+ const connectionIds = await debugHandle.getConnectionIds();
942
+ expect3(connectionIds).toContain(connState.id);
943
+ });
944
+ await vi3.waitFor(async () => {
945
+ const disconnects = await debugHandle.getDisconnectionCount();
946
+ expect3(disconnects).toBe(0);
947
+ });
959
948
  await conn.dispose();
960
- const newConn = handle.connect();
961
- await vi2.waitFor(async () => {
962
- const newDisconnections = await newConn.getDisconnectionCount();
963
- expect3(newDisconnections).toBeGreaterThan(initialDisconnections);
949
+ await vi3.waitFor(
950
+ async () => {
951
+ console.log("disconnects before");
952
+ const disconnects = await debugHandle.getDisconnectionCount();
953
+ console.log("disconnects", disconnects);
954
+ expect3(disconnects).toBe(1);
955
+ },
956
+ // SSE takes a long time to disconnect on CF Workers
957
+ {
958
+ timeout: 1e4,
959
+ interval: 100
960
+ }
961
+ );
962
+ const newConn = client.connStateActor.getOrCreate().connect();
963
+ await vi3.waitFor(async () => {
964
+ const connectionIds = await debugHandle.getConnectionIds();
965
+ console.log("conn ids", connectionIds);
966
+ expect3(connectionIds.length).toBe(1);
964
967
  });
965
968
  await newConn.dispose();
969
+ await vi3.waitFor(
970
+ async () => {
971
+ console.log("A");
972
+ const disconnects = await debugHandle.getDisconnectionCount();
973
+ console.log(`B ${disconnects}`);
974
+ expect3(disconnects).toBe(2);
975
+ },
976
+ // SSE takes a long time to disconnect on CF Workers
977
+ {
978
+ timeout: 1e4,
979
+ interval: 100
980
+ }
981
+ );
966
982
  });
967
983
  test3("should update connection state", async (c) => {
968
984
  const { client } = await setupDriverTest(c, driverTestConfig);
@@ -993,14 +1009,16 @@ function runActorConnStateTests(driverTestConfig) {
993
1009
  conn2.on("directMessage", (data) => {
994
1010
  receivedMessages.push(data);
995
1011
  });
996
- const success = await conn1.sendToConnection(
997
- state2.id,
998
- "Hello from conn1"
999
- );
1000
- expect3(success).toBe(true);
1001
- expect3(receivedMessages.length).toBe(1);
1002
- expect3(receivedMessages[0].from).toBe(state1.id);
1003
- expect3(receivedMessages[0].message).toBe("Hello from conn1");
1012
+ await vi3.waitFor(async () => {
1013
+ const success = await conn1.sendToConnection(
1014
+ state2.id,
1015
+ "Hello from conn1"
1016
+ );
1017
+ expect3(success).toBe(true);
1018
+ expect3(receivedMessages.length).toBe(1);
1019
+ expect3(receivedMessages[0].from).toBe(state1.id);
1020
+ expect3(receivedMessages[0].message).toBe("Hello from conn1");
1021
+ });
1004
1022
  await conn1.dispose();
1005
1023
  await conn2.dispose();
1006
1024
  });
@@ -1120,7 +1138,7 @@ var sleepWithLongRpc = actor({
1120
1138
  },
1121
1139
  longRunningRpc: async (c) => {
1122
1140
  c.log.info("starting long running rpc");
1123
- c.vars.longRunningResolve = Promise.withResolvers();
1141
+ c.vars.longRunningResolve = promiseWithResolvers();
1124
1142
  c.broadcast("waiting");
1125
1143
  await c.vars.longRunningResolve.promise;
1126
1144
  c.log.info("finished long running rpc");
@@ -1447,7 +1465,6 @@ function runActorSleepTests(driverTestConfig) {
1447
1465
  expect5(counts.sleepCount).toBe(0);
1448
1466
  expect5(counts.startCount).toBe(1);
1449
1467
  ws.close();
1450
- await new Promise((resolve) => setTimeout(resolve, 100));
1451
1468
  await waitFor(driverTestConfig, SLEEP_TIMEOUT + 100);
1452
1469
  {
1453
1470
  const { startCount, sleepCount } = await sleepActor.getCounts();
@@ -2515,117 +2532,214 @@ function runActorOnStateChangeTests(driverTestConfig) {
2515
2532
  });
2516
2533
  }
2517
2534
 
2535
+ // src/driver-test-suite/tests/actor-reconnect.ts
2536
+ import { describe as describe14, expect as expect13, test as test13, vi as vi4 } from "vitest";
2537
+ function runActorReconnectTests(driverTestConfig) {
2538
+ describe14("Actor Reconnection Tests", () => {
2539
+ test13("should reconnect and preserve connection state after non-clean disconnect", async (c) => {
2540
+ const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2541
+ const handle = client.counterConn.getOrCreate(["test-reconnect"]);
2542
+ const connection = handle.connect();
2543
+ await connection.increment(5);
2544
+ const connCount1 = await connection.getConnectionCount();
2545
+ expect13(connCount1).toBe(1);
2546
+ const connRaw = connection;
2547
+ await forceUncleanDisconnect(
2548
+ endpoint,
2549
+ connRaw.actorId,
2550
+ connRaw.connectionId
2551
+ );
2552
+ await vi4.waitFor(
2553
+ async () => {
2554
+ const countAfterReconnect = await connection.getCount();
2555
+ expect13(countAfterReconnect).toBe(5);
2556
+ },
2557
+ { timeout: 5e3, interval: 100 }
2558
+ );
2559
+ const connCount2 = await connection.getConnectionCount();
2560
+ expect13(connCount2).toBe(1);
2561
+ const newCount = await connection.getCount();
2562
+ expect13(newCount).toBe(5);
2563
+ await connection.dispose();
2564
+ });
2565
+ test13("should not preserve connection state after clean disconnect", async (c) => {
2566
+ const { client } = await setupDriverTest(c, driverTestConfig);
2567
+ const handle = client.counterConn.getOrCreate(["test-clean-disconnect"]);
2568
+ const connection = handle.connect();
2569
+ await connection.increment(10);
2570
+ const connCount1 = await connection.getConnectionCount();
2571
+ expect13(connCount1).toBe(1);
2572
+ await connection.dispose();
2573
+ await vi4.waitFor(
2574
+ async () => {
2575
+ const handle2 = client.counterConn.get(["test-clean-disconnect"]);
2576
+ const connCount = await handle2.getConnectionCount();
2577
+ expect13(connCount).toBe(1);
2578
+ },
2579
+ { timeout: 5e3 }
2580
+ );
2581
+ const connection2 = handle.connect();
2582
+ const countNewConnection = await connection2.getCount();
2583
+ expect13(countNewConnection).toBe(0);
2584
+ const connCount3 = await connection2.getConnectionCount();
2585
+ expect13(connCount3).toBe(1);
2586
+ await connection2.dispose();
2587
+ });
2588
+ test13("should handle multiple non-clean disconnects and reconnects", async (c) => {
2589
+ const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
2590
+ const handle = client.counterConn.getOrCreate([
2591
+ "test-multiple-reconnect"
2592
+ ]);
2593
+ const connection = handle.connect();
2594
+ await connection.setCount(100);
2595
+ for (let i = 0; i < 3; i++) {
2596
+ await connection.increment(1);
2597
+ const connRaw = connection;
2598
+ await forceUncleanDisconnect(
2599
+ endpoint,
2600
+ connRaw.actorId,
2601
+ connRaw.connectionId
2602
+ );
2603
+ await vi4.waitFor(
2604
+ async () => {
2605
+ const countAfter = await connection.getCount();
2606
+ expect13(countAfter).toBe(101 + i);
2607
+ },
2608
+ { timeout: 5e3 }
2609
+ );
2610
+ const connCount = await connection.getConnectionCount();
2611
+ expect13(connCount).toBe(1);
2612
+ }
2613
+ const finalCount = await connection.getCount();
2614
+ expect13(finalCount).toBe(103);
2615
+ await connection.dispose();
2616
+ });
2617
+ });
2618
+ }
2619
+ async function forceUncleanDisconnect(endpoint, actorId, connId) {
2620
+ const response = await fetch(
2621
+ `${endpoint}/.test/force-disconnect?actor=${actorId}&conn=${connId}`,
2622
+ {
2623
+ method: "POST"
2624
+ }
2625
+ );
2626
+ if (!response.ok) {
2627
+ const text = await response.text();
2628
+ throw new Error(`Failed to force disconnect: ${text}`);
2629
+ }
2630
+ }
2631
+
2518
2632
  // src/driver-test-suite/tests/actor-vars.ts
2519
- import { describe as describe14, expect as expect13, test as test13 } from "vitest";
2633
+ import { describe as describe15, expect as expect14, test as test14 } from "vitest";
2520
2634
  function runActorVarsTests(driverTestConfig) {
2521
- describe14("Actor Variables", () => {
2522
- describe14("Static vars", () => {
2523
- test13("should provide access to static vars", async (c) => {
2635
+ describe15("Actor Variables", () => {
2636
+ describe15("Static vars", () => {
2637
+ test14("should provide access to static vars", async (c) => {
2524
2638
  const { client } = await setupDriverTest(c, driverTestConfig);
2525
2639
  const instance = client.staticVarActor.getOrCreate();
2526
2640
  const result = await instance.getVars();
2527
- expect13(result).toEqual({ counter: 42, name: "test-actor" });
2641
+ expect14(result).toEqual({ counter: 42, name: "test-actor" });
2528
2642
  const name = await instance.getName();
2529
- expect13(name).toBe("test-actor");
2643
+ expect14(name).toBe("test-actor");
2530
2644
  });
2531
2645
  });
2532
- describe14("Deep cloning of static vars", () => {
2533
- test13("should deep clone static vars between actor instances", async (c) => {
2646
+ describe15("Deep cloning of static vars", () => {
2647
+ test14("should deep clone static vars between actor instances", async (c) => {
2534
2648
  const { client } = await setupDriverTest(c, driverTestConfig);
2535
2649
  const instance1 = client.nestedVarActor.getOrCreate(["instance1"]);
2536
2650
  const instance2 = client.nestedVarActor.getOrCreate(["instance2"]);
2537
2651
  const modifiedVars = await instance1.modifyNested();
2538
- expect13(modifiedVars.nested.value).toBe("modified");
2539
- expect13(modifiedVars.nested.array).toContain(4);
2540
- expect13(modifiedVars.nested.obj.key).toBe("new-value");
2652
+ expect14(modifiedVars.nested.value).toBe("modified");
2653
+ expect14(modifiedVars.nested.array).toContain(4);
2654
+ expect14(modifiedVars.nested.obj.key).toBe("new-value");
2541
2655
  const instance2Vars = await instance2.getVars();
2542
- expect13(instance2Vars.nested.value).toBe("original");
2543
- expect13(instance2Vars.nested.array).toEqual([1, 2, 3]);
2544
- expect13(instance2Vars.nested.obj.key).toBe("value");
2656
+ expect14(instance2Vars.nested.value).toBe("original");
2657
+ expect14(instance2Vars.nested.array).toEqual([1, 2, 3]);
2658
+ expect14(instance2Vars.nested.obj.key).toBe("value");
2545
2659
  });
2546
2660
  });
2547
- describe14("createVars", () => {
2548
- test13("should support dynamic vars creation", async (c) => {
2661
+ describe15("createVars", () => {
2662
+ test14("should support dynamic vars creation", async (c) => {
2549
2663
  const { client } = await setupDriverTest(c, driverTestConfig);
2550
2664
  const instance = client.dynamicVarActor.getOrCreate();
2551
2665
  const vars = await instance.getVars();
2552
- expect13(vars).toHaveProperty("random");
2553
- expect13(vars).toHaveProperty("computed");
2554
- expect13(typeof vars.random).toBe("number");
2555
- expect13(typeof vars.computed).toBe("string");
2556
- expect13(vars.computed).toMatch(/^Actor-\d+$/);
2666
+ expect14(vars).toHaveProperty("random");
2667
+ expect14(vars).toHaveProperty("computed");
2668
+ expect14(typeof vars.random).toBe("number");
2669
+ expect14(typeof vars.computed).toBe("string");
2670
+ expect14(vars.computed).toMatch(/^Actor-\d+$/);
2557
2671
  });
2558
- test13("should create different vars for different instances", async (c) => {
2672
+ test14("should create different vars for different instances", async (c) => {
2559
2673
  const { client } = await setupDriverTest(c, driverTestConfig);
2560
2674
  const instance1 = client.uniqueVarActor.getOrCreate(["test1"]);
2561
2675
  const instance2 = client.uniqueVarActor.getOrCreate(["test2"]);
2562
2676
  const vars1 = await instance1.getVars();
2563
2677
  const vars2 = await instance2.getVars();
2564
- expect13(vars1.id).not.toBe(vars2.id);
2678
+ expect14(vars1.id).not.toBe(vars2.id);
2565
2679
  });
2566
2680
  });
2567
- describe14("Driver Context", () => {
2568
- test13("should provide access to driver context", async (c) => {
2681
+ describe15("Driver Context", () => {
2682
+ test14("should provide access to driver context", async (c) => {
2569
2683
  const { client } = await setupDriverTest(c, driverTestConfig);
2570
2684
  const instance = client.driverCtxActor.getOrCreate();
2571
2685
  const vars = await instance.getVars();
2572
- expect13(vars).toHaveProperty("hasDriverCtx");
2686
+ expect14(vars).toHaveProperty("hasDriverCtx");
2573
2687
  });
2574
2688
  });
2575
2689
  });
2576
2690
  }
2577
2691
 
2578
2692
  // src/driver-test-suite/tests/manager-driver.ts
2579
- import { describe as describe15, expect as expect14, test as test14 } from "vitest";
2693
+ import { describe as describe16, expect as expect15, test as test15 } from "vitest";
2580
2694
  function runManagerDriverTests(driverTestConfig) {
2581
- describe15("Manager Driver Tests", () => {
2582
- describe15("Client Connection Methods", () => {
2583
- test14("connect() - finds or creates a actor", async (c) => {
2695
+ describe16("Manager Driver Tests", () => {
2696
+ describe16("Client Connection Methods", () => {
2697
+ test15("connect() - finds or creates a actor", async (c) => {
2584
2698
  const { client } = await setupDriverTest(c, driverTestConfig);
2585
2699
  const counterA = client.counter.getOrCreate();
2586
2700
  await counterA.increment(5);
2587
2701
  const counterAAgain = client.counter.getOrCreate();
2588
2702
  const count = await counterAAgain.increment(0);
2589
- expect14(count).toBe(5);
2703
+ expect15(count).toBe(5);
2590
2704
  const counterB = client.counter.getOrCreate(["counter-b", "testing"]);
2591
2705
  await counterB.increment(10);
2592
2706
  const countB = await counterB.increment(0);
2593
- expect14(countB).toBe(10);
2707
+ expect15(countB).toBe(10);
2594
2708
  });
2595
- test14("throws ActorAlreadyExists when creating duplicate actors", async (c) => {
2709
+ test15("throws ActorAlreadyExists when creating duplicate actors", async (c) => {
2596
2710
  const { client } = await setupDriverTest(c, driverTestConfig);
2597
2711
  const uniqueKey = ["duplicate-actor-test", crypto.randomUUID()];
2598
2712
  const counter = client.counter.getOrCreate(uniqueKey);
2599
2713
  await counter.increment(5);
2600
2714
  try {
2601
2715
  await client.counter.create(uniqueKey);
2602
- expect14.fail("did not error on duplicate create");
2716
+ expect15.fail("did not error on duplicate create");
2603
2717
  } catch (err) {
2604
- expect14(err.group).toBe("actor");
2605
- expect14(err.code).toBe("already_exists");
2718
+ expect15(err.group).toBe("actor");
2719
+ expect15(err.code).toBe("already_exists");
2606
2720
  }
2607
2721
  const count = await counter.increment(0);
2608
- expect14(count).toBe(5);
2722
+ expect15(count).toBe(5);
2609
2723
  });
2610
2724
  });
2611
- describe15("Connection Options", () => {
2612
- test14("get without create prevents actor creation", async (c) => {
2725
+ describe16("Connection Options", () => {
2726
+ test15("get without create prevents actor creation", async (c) => {
2613
2727
  const { client } = await setupDriverTest(c, driverTestConfig);
2614
2728
  const nonexistentId = `nonexistent-${crypto.randomUUID()}`;
2615
2729
  try {
2616
2730
  await client.counter.get([nonexistentId]).resolve();
2617
- expect14.fail("did not error for get");
2731
+ expect15.fail("did not error for get");
2618
2732
  } catch (err) {
2619
- expect14(err.group).toBe("actor");
2620
- expect14(err.code).toBe("not_found");
2733
+ expect15(err.group).toBe("actor");
2734
+ expect15(err.code).toBe("not_found");
2621
2735
  }
2622
2736
  const createdCounter = client.counter.getOrCreate(nonexistentId);
2623
2737
  await createdCounter.increment(3);
2624
2738
  const retrievedCounter = client.counter.get(nonexistentId);
2625
2739
  const count = await retrievedCounter.increment(0);
2626
- expect14(count).toBe(3);
2740
+ expect15(count).toBe(3);
2627
2741
  });
2628
- test14("connection params are passed to actors", async (c) => {
2742
+ test15("connection params are passed to actors", async (c) => {
2629
2743
  const { client } = await setupDriverTest(c, driverTestConfig);
2630
2744
  const counter = client.counter.getOrCreate(void 0, {
2631
2745
  params: {
@@ -2636,20 +2750,20 @@ function runManagerDriverTests(driverTestConfig) {
2636
2750
  });
2637
2751
  await counter.increment(1);
2638
2752
  const count = await counter.increment(0);
2639
- expect14(count).toBe(1);
2753
+ expect15(count).toBe(1);
2640
2754
  });
2641
2755
  });
2642
- describe15("Actor Creation & Retrieval", () => {
2643
- test14("creates and retrieves actors by ID", async (c) => {
2756
+ describe16("Actor Creation & Retrieval", () => {
2757
+ test15("creates and retrieves actors by ID", async (c) => {
2644
2758
  const { client } = await setupDriverTest(c, driverTestConfig);
2645
2759
  const uniqueId = `test-counter-${crypto.randomUUID()}`;
2646
2760
  const counter = client.counter.getOrCreate([uniqueId]);
2647
2761
  await counter.increment(10);
2648
2762
  const retrievedCounter = client.counter.getOrCreate([uniqueId]);
2649
2763
  const count = await retrievedCounter.increment(0);
2650
- expect14(count).toBe(10);
2764
+ expect15(count).toBe(10);
2651
2765
  });
2652
- test14("passes input to actor during creation", async (c) => {
2766
+ test15("passes input to actor during creation", async (c) => {
2653
2767
  const { client } = await setupDriverTest(c, driverTestConfig);
2654
2768
  const testInput = {
2655
2769
  name: "test-actor",
@@ -2660,17 +2774,17 @@ function runManagerDriverTests(driverTestConfig) {
2660
2774
  input: testInput
2661
2775
  });
2662
2776
  const inputs = await actor2.getInputs();
2663
- expect14(inputs.initialInput).toEqual(testInput);
2664
- expect14(inputs.onCreateInput).toEqual(testInput);
2777
+ expect15(inputs.initialInput).toEqual(testInput);
2778
+ expect15(inputs.onCreateInput).toEqual(testInput);
2665
2779
  });
2666
- test14("input is undefined when not provided", async (c) => {
2780
+ test15("input is undefined when not provided", async (c) => {
2667
2781
  const { client } = await setupDriverTest(c, driverTestConfig);
2668
2782
  const actor2 = await client.inputActor.create();
2669
2783
  const inputs = await actor2.getInputs();
2670
- expect14(inputs.initialInput).toBeUndefined();
2671
- expect14(inputs.onCreateInput).toBeUndefined();
2784
+ expect15(inputs.initialInput).toBeUndefined();
2785
+ expect15(inputs.onCreateInput).toBeUndefined();
2672
2786
  });
2673
- test14("getOrCreate passes input to actor during creation", async (c) => {
2787
+ test15("getOrCreate passes input to actor during creation", async (c) => {
2674
2788
  const { client } = await setupDriverTest(c, driverTestConfig);
2675
2789
  const uniqueKey = [`input-test-${crypto.randomUUID()}`];
2676
2790
  const testInput = {
@@ -2682,16 +2796,16 @@ function runManagerDriverTests(driverTestConfig) {
2682
2796
  createWithInput: testInput
2683
2797
  });
2684
2798
  const inputs = await actor2.getInputs();
2685
- expect14(inputs.initialInput).toEqual(testInput);
2686
- expect14(inputs.onCreateInput).toEqual(testInput);
2799
+ expect15(inputs.initialInput).toEqual(testInput);
2800
+ expect15(inputs.onCreateInput).toEqual(testInput);
2687
2801
  const existingActor = client.inputActor.getOrCreate(uniqueKey);
2688
2802
  const existingInputs = await existingActor.getInputs();
2689
- expect14(existingInputs.initialInput).toEqual(testInput);
2690
- expect14(existingInputs.onCreateInput).toEqual(testInput);
2803
+ expect15(existingInputs.initialInput).toEqual(testInput);
2804
+ expect15(existingInputs.onCreateInput).toEqual(testInput);
2691
2805
  });
2692
2806
  });
2693
- describe15("Key Matching", () => {
2694
- test14("matches actors only with exactly the same keys", async (c) => {
2807
+ describe16("Key Matching", () => {
2808
+ test15("matches actors only with exactly the same keys", async (c) => {
2695
2809
  const { client } = await setupDriverTest(c, driverTestConfig);
2696
2810
  const originalCounter = client.counter.getOrCreate([
2697
2811
  "counter-match",
@@ -2705,37 +2819,37 @@ function runManagerDriverTests(driverTestConfig) {
2705
2819
  "us-east"
2706
2820
  ]);
2707
2821
  const exactMatchCount = await exactMatchCounter.increment(0);
2708
- expect14(exactMatchCount).toBe(10);
2822
+ expect15(exactMatchCount).toBe(10);
2709
2823
  const subsetMatchCounter = client.counter.getOrCreate([
2710
2824
  "counter-match",
2711
2825
  "test"
2712
2826
  ]);
2713
2827
  const subsetMatchCount = await subsetMatchCounter.increment(0);
2714
- expect14(subsetMatchCount).toBe(0);
2828
+ expect15(subsetMatchCount).toBe(0);
2715
2829
  const singleKeyCounter = client.counter.getOrCreate(["counter-match"]);
2716
2830
  const singleKeyCount = await singleKeyCounter.increment(0);
2717
- expect14(singleKeyCount).toBe(0);
2831
+ expect15(singleKeyCount).toBe(0);
2718
2832
  });
2719
- test14("string key matches array with single string key", async (c) => {
2833
+ test15("string key matches array with single string key", async (c) => {
2720
2834
  const { client } = await setupDriverTest(c, driverTestConfig);
2721
2835
  const stringKeyCounter = client.counter.getOrCreate("string-key-test");
2722
2836
  await stringKeyCounter.increment(7);
2723
2837
  const arrayKeyCounter = client.counter.getOrCreate(["string-key-test"]);
2724
2838
  const count = await arrayKeyCounter.increment(0);
2725
- expect14(count).toBe(7);
2839
+ expect15(count).toBe(7);
2726
2840
  });
2727
- test14("undefined key matches empty array key and no key", async (c) => {
2841
+ test15("undefined key matches empty array key and no key", async (c) => {
2728
2842
  const { client } = await setupDriverTest(c, driverTestConfig);
2729
2843
  const undefinedKeyCounter = client.counter.getOrCreate(void 0);
2730
2844
  await undefinedKeyCounter.increment(12);
2731
2845
  const emptyArrayKeyCounter = client.counter.getOrCreate([]);
2732
2846
  const emptyArrayCount = await emptyArrayKeyCounter.increment(0);
2733
- expect14(emptyArrayCount).toBe(12);
2847
+ expect15(emptyArrayCount).toBe(12);
2734
2848
  const noKeyCounter = client.counter.getOrCreate();
2735
2849
  const noKeyCount = await noKeyCounter.increment(0);
2736
- expect14(noKeyCount).toBe(12);
2850
+ expect15(noKeyCount).toBe(12);
2737
2851
  });
2738
- test14("no keys does not match actors with keys", async (c) => {
2852
+ test15("no keys does not match actors with keys", async (c) => {
2739
2853
  const { client } = await setupDriverTest(c, driverTestConfig);
2740
2854
  const keyedCounter = client.counter.getOrCreate([
2741
2855
  "counter-with-keys",
@@ -2744,9 +2858,9 @@ function runManagerDriverTests(driverTestConfig) {
2744
2858
  await keyedCounter.increment(15);
2745
2859
  const noKeysCounter = client.counter.getOrCreate();
2746
2860
  const count = await noKeysCounter.increment(10);
2747
- expect14(count).toBe(10);
2861
+ expect15(count).toBe(10);
2748
2862
  });
2749
- test14("actors with keys match actors with no keys", async (c) => {
2863
+ test15("actors with keys match actors with no keys", async (c) => {
2750
2864
  const { client } = await setupDriverTest(c, driverTestConfig);
2751
2865
  const noKeysCounter = client.counter.getOrCreate();
2752
2866
  await noKeysCounter.increment(25);
@@ -2755,11 +2869,11 @@ function runManagerDriverTests(driverTestConfig) {
2755
2869
  "prod"
2756
2870
  ]);
2757
2871
  const keyedCount = await keyedCounter.increment(0);
2758
- expect14(keyedCount).toBe(0);
2872
+ expect15(keyedCount).toBe(0);
2759
2873
  });
2760
2874
  });
2761
- describe15("Multiple Actor Instances", () => {
2762
- test14("creates multiple actor instances of the same type", async (c) => {
2875
+ describe16("Multiple Actor Instances", () => {
2876
+ test15("creates multiple actor instances of the same type", async (c) => {
2763
2877
  const { client } = await setupDriverTest(c, driverTestConfig);
2764
2878
  const instance1 = client.counter.getOrCreate(["multi-1"]);
2765
2879
  const instance2 = client.counter.getOrCreate(["multi-2"]);
@@ -2770,35 +2884,35 @@ function runManagerDriverTests(driverTestConfig) {
2770
2884
  const retrieved1 = client.counter.getOrCreate(["multi-1"]);
2771
2885
  const retrieved2 = client.counter.getOrCreate(["multi-2"]);
2772
2886
  const retrieved3 = client.counter.getOrCreate(["multi-3"]);
2773
- expect14(await retrieved1.increment(0)).toBe(1);
2774
- expect14(await retrieved2.increment(0)).toBe(2);
2775
- expect14(await retrieved3.increment(0)).toBe(3);
2887
+ expect15(await retrieved1.increment(0)).toBe(1);
2888
+ expect15(await retrieved2.increment(0)).toBe(2);
2889
+ expect15(await retrieved3.increment(0)).toBe(3);
2776
2890
  });
2777
- test14("handles default instance with no explicit ID", async (c) => {
2891
+ test15("handles default instance with no explicit ID", async (c) => {
2778
2892
  const { client } = await setupDriverTest(c, driverTestConfig);
2779
2893
  const defaultCounter = client.counter.getOrCreate();
2780
2894
  await defaultCounter.increment(5);
2781
2895
  const sameDefaultCounter = client.counter.getOrCreate();
2782
2896
  const count = await sameDefaultCounter.increment(0);
2783
- expect14(count).toBe(5);
2897
+ expect15(count).toBe(5);
2784
2898
  });
2785
2899
  });
2786
2900
  });
2787
2901
  }
2788
2902
 
2789
2903
  // src/driver-test-suite/tests/raw-http.ts
2790
- import { describe as describe16, expect as expect15, test as test15 } from "vitest";
2904
+ import { describe as describe17, expect as expect16, test as test16 } from "vitest";
2791
2905
  function runRawHttpTests(driverTestConfig) {
2792
- describe16("raw http", () => {
2793
- test15("should handle raw HTTP GET requests", async (c) => {
2906
+ describe17("raw http", () => {
2907
+ test16("should handle raw HTTP GET requests", async (c) => {
2794
2908
  const { client } = await setupDriverTest(c, driverTestConfig);
2795
2909
  const actor2 = client.rawHttpActor.getOrCreate(["test"]);
2796
2910
  const helloResponse = await actor2.fetch("api/hello");
2797
- expect15(helloResponse.ok).toBe(true);
2911
+ expect16(helloResponse.ok).toBe(true);
2798
2912
  const helloData = await helloResponse.json();
2799
- expect15(helloData).toEqual({ message: "Hello from actor!" });
2913
+ expect16(helloData).toEqual({ message: "Hello from actor!" });
2800
2914
  });
2801
- test15("should handle raw HTTP POST requests with echo", async (c) => {
2915
+ test16("should handle raw HTTP POST requests with echo", async (c) => {
2802
2916
  const { client } = await setupDriverTest(c, driverTestConfig);
2803
2917
  const actor2 = client.rawHttpActor.getOrCreate(["test"]);
2804
2918
  const testData = { test: "data", number: 123 };
@@ -2809,22 +2923,22 @@ function runRawHttpTests(driverTestConfig) {
2809
2923
  },
2810
2924
  body: JSON.stringify(testData)
2811
2925
  });
2812
- expect15(echoResponse.ok).toBe(true);
2926
+ expect16(echoResponse.ok).toBe(true);
2813
2927
  const echoData = await echoResponse.json();
2814
- expect15(echoData).toEqual(testData);
2928
+ expect16(echoData).toEqual(testData);
2815
2929
  });
2816
- test15("should track state across raw HTTP requests", async (c) => {
2930
+ test16("should track state across raw HTTP requests", async (c) => {
2817
2931
  const { client } = await setupDriverTest(c, driverTestConfig);
2818
2932
  const actor2 = client.rawHttpActor.getOrCreate(["state-test"]);
2819
2933
  await actor2.fetch("api/hello");
2820
2934
  await actor2.fetch("api/hello");
2821
2935
  await actor2.fetch("api/state");
2822
2936
  const stateResponse = await actor2.fetch("api/state");
2823
- expect15(stateResponse.ok).toBe(true);
2937
+ expect16(stateResponse.ok).toBe(true);
2824
2938
  const stateData = await stateResponse.json();
2825
- expect15(stateData.requestCount).toBe(4);
2939
+ expect16(stateData.requestCount).toBe(4);
2826
2940
  });
2827
- test15("should pass headers correctly", async (c) => {
2941
+ test16("should pass headers correctly", async (c) => {
2828
2942
  const { client } = await setupDriverTest(c, driverTestConfig);
2829
2943
  const actor2 = client.rawHttpActor.getOrCreate(["headers-test"]);
2830
2944
  const customHeaders = {
@@ -2834,40 +2948,40 @@ function runRawHttpTests(driverTestConfig) {
2834
2948
  const response = await actor2.fetch("api/headers", {
2835
2949
  headers: customHeaders
2836
2950
  });
2837
- expect15(response.ok).toBe(true);
2951
+ expect16(response.ok).toBe(true);
2838
2952
  const headers = await response.json();
2839
- expect15(headers["x-custom-header"]).toBe("test-value");
2840
- expect15(headers["x-another-header"]).toBe("another-value");
2953
+ expect16(headers["x-custom-header"]).toBe("test-value");
2954
+ expect16(headers["x-another-header"]).toBe("another-value");
2841
2955
  });
2842
- test15("should return 404 for unhandled paths", async (c) => {
2956
+ test16("should return 404 for unhandled paths", async (c) => {
2843
2957
  const { client } = await setupDriverTest(c, driverTestConfig);
2844
2958
  const actor2 = client.rawHttpActor.getOrCreate(["404-test"]);
2845
2959
  const response = await actor2.fetch("api/nonexistent");
2846
- expect15(response.ok).toBe(false);
2847
- expect15(response.status).toBe(404);
2960
+ expect16(response.ok).toBe(false);
2961
+ expect16(response.status).toBe(404);
2848
2962
  });
2849
- test15("should return 404 when no onFetch handler defined", async (c) => {
2963
+ test16("should return 404 when no onFetch handler defined", async (c) => {
2850
2964
  const { client } = await setupDriverTest(c, driverTestConfig);
2851
2965
  const actor2 = client.rawHttpNoHandlerActor.getOrCreate(["no-handler"]);
2852
2966
  const response = await actor2.fetch("api/anything");
2853
- expect15(response.ok).toBe(false);
2854
- expect15(response.status).toBe(404);
2967
+ expect16(response.ok).toBe(false);
2968
+ expect16(response.status).toBe(404);
2855
2969
  });
2856
- test15("should return 500 error when onFetch returns void", async (c) => {
2970
+ test16("should return 500 error when onFetch returns void", async (c) => {
2857
2971
  const { client } = await setupDriverTest(c, driverTestConfig);
2858
2972
  const actor2 = client.rawHttpVoidReturnActor.getOrCreate(["void-return"]);
2859
2973
  const response = await actor2.fetch("api/anything");
2860
- expect15(response.ok).toBe(false);
2861
- expect15(response.status).toBe(500);
2974
+ expect16(response.ok).toBe(false);
2975
+ expect16(response.status).toBe(500);
2862
2976
  try {
2863
2977
  const errorData = await response.json();
2864
- expect15(errorData.message).toContain(
2978
+ expect16(errorData.message).toContain(
2865
2979
  "onFetch handler must return a Response"
2866
2980
  );
2867
2981
  } catch {
2868
2982
  }
2869
2983
  });
2870
- test15("should handle different HTTP methods", async (c) => {
2984
+ test16("should handle different HTTP methods", async (c) => {
2871
2985
  const { client } = await setupDriverTest(c, driverTestConfig);
2872
2986
  const actor2 = client.rawHttpActor.getOrCreate(["methods-test"]);
2873
2987
  const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
@@ -2877,17 +2991,17 @@ function runRawHttpTests(driverTestConfig) {
2877
2991
  body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
2878
2992
  });
2879
2993
  if (method === "POST") {
2880
- expect15(response.ok).toBe(true);
2994
+ expect16(response.ok).toBe(true);
2881
2995
  const data = await response.json();
2882
- expect15(data).toEqual({ method });
2996
+ expect16(data).toEqual({ method });
2883
2997
  } else if (method === "GET") {
2884
- expect15(response.status).toBe(404);
2998
+ expect16(response.status).toBe(404);
2885
2999
  } else {
2886
- expect15(response.status).toBe(404);
3000
+ expect16(response.status).toBe(404);
2887
3001
  }
2888
3002
  }
2889
3003
  });
2890
- test15("should handle binary data", async (c) => {
3004
+ test16("should handle binary data", async (c) => {
2891
3005
  const { client } = await setupDriverTest(c, driverTestConfig);
2892
3006
  const actor2 = client.rawHttpActor.getOrCreate(["binary-test"]);
2893
3007
  const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
@@ -2898,82 +3012,82 @@ function runRawHttpTests(driverTestConfig) {
2898
3012
  },
2899
3013
  body: binaryData
2900
3014
  });
2901
- expect15(response.ok).toBe(true);
3015
+ expect16(response.ok).toBe(true);
2902
3016
  const responseBuffer = await response.arrayBuffer();
2903
3017
  const responseArray = new Uint8Array(responseBuffer);
2904
- expect15(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
3018
+ expect16(Array.from(responseArray)).toEqual([1, 2, 3, 4, 5]);
2905
3019
  });
2906
- test15("should work with Hono router using createVars", async (c) => {
3020
+ test16("should work with Hono router using createVars", async (c) => {
2907
3021
  const { client } = await setupDriverTest(c, driverTestConfig);
2908
3022
  const actor2 = client.rawHttpHonoActor.getOrCreate(["hono-test"]);
2909
3023
  const rootResponse = await actor2.fetch("/");
2910
- expect15(rootResponse.ok).toBe(true);
3024
+ expect16(rootResponse.ok).toBe(true);
2911
3025
  const rootData = await rootResponse.json();
2912
- expect15(rootData).toEqual({ message: "Welcome to Hono actor!" });
3026
+ expect16(rootData).toEqual({ message: "Welcome to Hono actor!" });
2913
3027
  const usersResponse = await actor2.fetch("/users");
2914
- expect15(usersResponse.ok).toBe(true);
3028
+ expect16(usersResponse.ok).toBe(true);
2915
3029
  const users = await usersResponse.json();
2916
- expect15(users).toEqual([
3030
+ expect16(users).toEqual([
2917
3031
  { id: 1, name: "Alice" },
2918
3032
  { id: 2, name: "Bob" }
2919
3033
  ]);
2920
3034
  const userResponse = await actor2.fetch("/users/1");
2921
- expect15(userResponse.ok).toBe(true);
3035
+ expect16(userResponse.ok).toBe(true);
2922
3036
  const user = await userResponse.json();
2923
- expect15(user).toEqual({ id: 1, name: "Alice" });
3037
+ expect16(user).toEqual({ id: 1, name: "Alice" });
2924
3038
  const newUser = { name: "Charlie" };
2925
3039
  const createResponse = await actor2.fetch("/users", {
2926
3040
  method: "POST",
2927
3041
  headers: { "Content-Type": "application/json" },
2928
3042
  body: JSON.stringify(newUser)
2929
3043
  });
2930
- expect15(createResponse.ok).toBe(true);
2931
- expect15(createResponse.status).toBe(201);
3044
+ expect16(createResponse.ok).toBe(true);
3045
+ expect16(createResponse.status).toBe(201);
2932
3046
  const createdUser = await createResponse.json();
2933
- expect15(createdUser).toEqual({ id: 3, name: "Charlie" });
3047
+ expect16(createdUser).toEqual({ id: 3, name: "Charlie" });
2934
3048
  const updateData = { name: "Alice Updated" };
2935
3049
  const updateResponse = await actor2.fetch("/users/1", {
2936
3050
  method: "PUT",
2937
3051
  headers: { "Content-Type": "application/json" },
2938
3052
  body: JSON.stringify(updateData)
2939
3053
  });
2940
- expect15(updateResponse.ok).toBe(true);
3054
+ expect16(updateResponse.ok).toBe(true);
2941
3055
  const updatedUser = await updateResponse.json();
2942
- expect15(updatedUser).toEqual({ id: 1, name: "Alice Updated" });
3056
+ expect16(updatedUser).toEqual({ id: 1, name: "Alice Updated" });
2943
3057
  const deleteResponse = await actor2.fetch("/users/2", {
2944
3058
  method: "DELETE"
2945
3059
  });
2946
- expect15(deleteResponse.ok).toBe(true);
3060
+ expect16(deleteResponse.ok).toBe(true);
2947
3061
  const deleteResult = await deleteResponse.json();
2948
- expect15(deleteResult).toEqual({ message: "User 2 deleted" });
3062
+ expect16(deleteResult).toEqual({ message: "User 2 deleted" });
2949
3063
  const notFoundResponse = await actor2.fetch("/api/unknown");
2950
- expect15(notFoundResponse.ok).toBe(false);
2951
- expect15(notFoundResponse.status).toBe(404);
3064
+ expect16(notFoundResponse.ok).toBe(false);
3065
+ expect16(notFoundResponse.status).toBe(404);
2952
3066
  });
2953
- test15("should handle paths with and without leading slashes", async (c) => {
3067
+ test16("should handle paths with and without leading slashes", async (c) => {
2954
3068
  const { client } = await setupDriverTest(c, driverTestConfig);
2955
3069
  const actor2 = client.rawHttpActor.getOrCreate(["path-test"]);
2956
3070
  const responseWithoutSlash = await actor2.fetch("api/hello");
2957
- expect15(responseWithoutSlash.ok).toBe(true);
3071
+ expect16(responseWithoutSlash.ok).toBe(true);
2958
3072
  const dataWithoutSlash = await responseWithoutSlash.json();
2959
- expect15(dataWithoutSlash).toEqual({ message: "Hello from actor!" });
3073
+ expect16(dataWithoutSlash).toEqual({ message: "Hello from actor!" });
2960
3074
  const responseWithSlash = await actor2.fetch("/api/hello");
2961
- expect15(responseWithSlash.ok).toBe(true);
3075
+ expect16(responseWithSlash.ok).toBe(true);
2962
3076
  const dataWithSlash = await responseWithSlash.json();
2963
- expect15(dataWithSlash).toEqual({ message: "Hello from actor!" });
3077
+ expect16(dataWithSlash).toEqual({ message: "Hello from actor!" });
2964
3078
  });
2965
- test15("should not create double slashes in request URLs", async (c) => {
3079
+ test16("should not create double slashes in request URLs", async (c) => {
2966
3080
  const { client } = await setupDriverTest(c, driverTestConfig);
2967
3081
  const actor2 = client.rawHttpHonoActor.getOrCreate(["url-test"]);
2968
3082
  const response = await actor2.fetch("/users");
2969
- expect15(response.ok).toBe(true);
3083
+ expect16(response.ok).toBe(true);
2970
3084
  const data = await response.json();
2971
- expect15(data).toEqual([
3085
+ expect16(data).toEqual([
2972
3086
  { id: 1, name: "Alice" },
2973
3087
  { id: 2, name: "Bob" }
2974
3088
  ]);
2975
3089
  });
2976
- test15("should handle forwarded requests correctly without double slashes", async (c) => {
3090
+ test16("should handle forwarded requests correctly without double slashes", async (c) => {
2977
3091
  const { client } = await setupDriverTest(c, driverTestConfig);
2978
3092
  const actor2 = client.rawHttpHonoActor.getOrCreate(["forward-test"]);
2979
3093
  const truncatedPath = "/users";
@@ -2982,14 +3096,14 @@ function runRawHttpTests(driverTestConfig) {
2982
3096
  method: "GET"
2983
3097
  });
2984
3098
  const response = await actor2.fetch(truncatedPath, newRequest);
2985
- expect15(response.ok).toBe(true);
3099
+ expect16(response.ok).toBe(true);
2986
3100
  const users = await response.json();
2987
- expect15(users).toEqual([
3101
+ expect16(users).toEqual([
2988
3102
  { id: 1, name: "Alice" },
2989
3103
  { id: 2, name: "Bob" }
2990
3104
  ]);
2991
3105
  });
2992
- test15("example fix: should properly forward requests using just Request object", async (c) => {
3106
+ test16("example fix: should properly forward requests using just Request object", async (c) => {
2993
3107
  const { client } = await setupDriverTest(c, driverTestConfig);
2994
3108
  const actor2 = client.rawHttpHonoActor.getOrCreate(["forward-fix"]);
2995
3109
  const truncatedPath = "/users/1";
@@ -2998,11 +3112,11 @@ function runRawHttpTests(driverTestConfig) {
2998
3112
  method: "GET"
2999
3113
  });
3000
3114
  const response = await actor2.fetch(newRequest);
3001
- expect15(response.ok).toBe(true);
3115
+ expect16(response.ok).toBe(true);
3002
3116
  const user = await response.json();
3003
- expect15(user).toEqual({ id: 1, name: "Alice" });
3117
+ expect16(user).toEqual({ id: 1, name: "Alice" });
3004
3118
  });
3005
- test15("should support standard fetch API with URL and Request objects", async (c) => {
3119
+ test16("should support standard fetch API with URL and Request objects", async (c) => {
3006
3120
  const { client } = await setupDriverTest(c, driverTestConfig);
3007
3121
  const actor2 = client.rawHttpActor.getOrCreate(["fetch-api-test"]);
3008
3122
  const url = new URL("/api/echo", "http://example.com");
@@ -3011,18 +3125,18 @@ function runRawHttpTests(driverTestConfig) {
3011
3125
  headers: { "Content-Type": "application/json" },
3012
3126
  body: JSON.stringify({ from: "URL object" })
3013
3127
  });
3014
- expect15(urlResponse.ok).toBe(true);
3128
+ expect16(urlResponse.ok).toBe(true);
3015
3129
  const urlData = await urlResponse.json();
3016
- expect15(urlData).toEqual({ from: "URL object" });
3130
+ expect16(urlData).toEqual({ from: "URL object" });
3017
3131
  const request = new Request("http://example.com/api/echo", {
3018
3132
  method: "POST",
3019
3133
  headers: { "Content-Type": "application/json" },
3020
3134
  body: JSON.stringify({ from: "Request object" })
3021
3135
  });
3022
3136
  const requestResponse = await actor2.fetch(request);
3023
- expect15(requestResponse.ok).toBe(true);
3137
+ expect16(requestResponse.ok).toBe(true);
3024
3138
  const requestData = await requestResponse.json();
3025
- expect15(requestData).toEqual({ from: "Request object" });
3139
+ expect16(requestData).toEqual({ from: "Request object" });
3026
3140
  const request2 = new Request("http://example.com/api/headers", {
3027
3141
  method: "GET",
3028
3142
  headers: { "X-Original": "request-header" }
@@ -3030,19 +3144,19 @@ function runRawHttpTests(driverTestConfig) {
3030
3144
  const overrideResponse = await actor2.fetch(request2, {
3031
3145
  headers: { "X-Override": "init-header" }
3032
3146
  });
3033
- expect15(overrideResponse.ok).toBe(true);
3147
+ expect16(overrideResponse.ok).toBe(true);
3034
3148
  const headers = await overrideResponse.json();
3035
- expect15(headers["x-override"]).toBe("init-header");
3036
- expect15(headers["x-original"]).toBe("request-header");
3149
+ expect16(headers["x-override"]).toBe("init-header");
3150
+ expect16(headers["x-original"]).toBe("request-header");
3037
3151
  });
3038
3152
  });
3039
3153
  }
3040
3154
 
3041
3155
  // src/driver-test-suite/tests/raw-http-request-properties.ts
3042
- import { describe as describe17, expect as expect16, test as test16 } from "vitest";
3156
+ import { describe as describe18, expect as expect17, test as test17 } from "vitest";
3043
3157
  function runRawHttpRequestPropertiesTests(driverTestConfig) {
3044
- describe17("raw http request properties", () => {
3045
- test16("should pass all Request properties correctly to onFetch", async (c) => {
3158
+ describe18("raw http request properties", () => {
3159
+ test17("should pass all Request properties correctly to onFetch", async (c) => {
3046
3160
  const { client } = await setupDriverTest(c, driverTestConfig);
3047
3161
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3048
3162
  const response = await actor2.fetch("test/path?foo=bar&baz=qux", {
@@ -3054,33 +3168,33 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3054
3168
  },
3055
3169
  body: JSON.stringify({ test: "data" })
3056
3170
  });
3057
- expect16(response.ok).toBe(true);
3171
+ expect17(response.ok).toBe(true);
3058
3172
  const data = await response.json();
3059
- expect16(data.url).toContain("/test/path?foo=bar&baz=qux");
3060
- expect16(data.pathname).toBe("/test/path");
3061
- expect16(data.search).toBe("?foo=bar&baz=qux");
3062
- expect16(data.searchParams).toEqual({
3173
+ expect17(data.url).toContain("/test/path?foo=bar&baz=qux");
3174
+ expect17(data.pathname).toBe("/test/path");
3175
+ expect17(data.search).toBe("?foo=bar&baz=qux");
3176
+ expect17(data.searchParams).toEqual({
3063
3177
  foo: "bar",
3064
3178
  baz: "qux"
3065
3179
  });
3066
- expect16(data.method).toBe("POST");
3067
- expect16(data.headers["content-type"]).toBe("application/json");
3068
- expect16(data.headers["x-custom-header"]).toBe("custom-value");
3069
- expect16(data.headers["authorization"]).toBe("Bearer test-token");
3070
- expect16(data.body).toEqual({ test: "data" });
3180
+ expect17(data.method).toBe("POST");
3181
+ expect17(data.headers["content-type"]).toBe("application/json");
3182
+ expect17(data.headers["x-custom-header"]).toBe("custom-value");
3183
+ expect17(data.headers["authorization"]).toBe("Bearer test-token");
3184
+ expect17(data.body).toEqual({ test: "data" });
3071
3185
  });
3072
- test16("should handle GET requests with no body", async (c) => {
3186
+ test17("should handle GET requests with no body", async (c) => {
3073
3187
  const { client } = await setupDriverTest(c, driverTestConfig);
3074
3188
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3075
3189
  const response = await actor2.fetch("test/get", {
3076
3190
  method: "GET"
3077
3191
  });
3078
- expect16(response.ok).toBe(true);
3192
+ expect17(response.ok).toBe(true);
3079
3193
  const data = await response.json();
3080
- expect16(data.method).toBe("GET");
3081
- expect16(data.body).toBeNull();
3194
+ expect17(data.method).toBe("GET");
3195
+ expect17(data.body).toBeNull();
3082
3196
  });
3083
- test16("should handle different content types", async (c) => {
3197
+ test17("should handle different content types", async (c) => {
3084
3198
  const { client } = await setupDriverTest(c, driverTestConfig);
3085
3199
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3086
3200
  const formData = new URLSearchParams();
@@ -3093,12 +3207,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3093
3207
  },
3094
3208
  body: formData.toString()
3095
3209
  });
3096
- expect16(formResponse.ok).toBe(true);
3210
+ expect17(formResponse.ok).toBe(true);
3097
3211
  const formResult = await formResponse.json();
3098
- expect16(formResult.headers["content-type"]).toBe(
3212
+ expect17(formResult.headers["content-type"]).toBe(
3099
3213
  "application/x-www-form-urlencoded"
3100
3214
  );
3101
- expect16(formResult.bodyText).toBe("field1=value1&field2=value2");
3215
+ expect17(formResult.bodyText).toBe("field1=value1&field2=value2");
3102
3216
  const textResponse = await actor2.fetch("test/text", {
3103
3217
  method: "POST",
3104
3218
  headers: {
@@ -3106,12 +3220,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3106
3220
  },
3107
3221
  body: "Hello, World!"
3108
3222
  });
3109
- expect16(textResponse.ok).toBe(true);
3223
+ expect17(textResponse.ok).toBe(true);
3110
3224
  const textResult = await textResponse.json();
3111
- expect16(textResult.headers["content-type"]).toBe("text/plain");
3112
- expect16(textResult.bodyText).toBe("Hello, World!");
3225
+ expect17(textResult.headers["content-type"]).toBe("text/plain");
3226
+ expect17(textResult.bodyText).toBe("Hello, World!");
3113
3227
  });
3114
- test16("should preserve all header casing and values", async (c) => {
3228
+ test17("should preserve all header casing and values", async (c) => {
3115
3229
  const { client } = await setupDriverTest(c, driverTestConfig);
3116
3230
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3117
3231
  const response = await actor2.fetch("test/headers", {
@@ -3123,34 +3237,34 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3123
3237
  "X-Request-ID": "12345"
3124
3238
  }
3125
3239
  });
3126
- expect16(response.ok).toBe(true);
3240
+ expect17(response.ok).toBe(true);
3127
3241
  const data = await response.json();
3128
- expect16(data.headers["accept"]).toBe("application/json");
3129
- expect16(data.headers["accept-language"]).toBe("en-US,en;q=0.9");
3130
- expect16(data.headers["cache-control"]).toBe("no-cache");
3131
- expect16(data.headers["user-agent"]).toBeTruthy();
3132
- expect16(data.headers["x-request-id"]).toBe("12345");
3242
+ expect17(data.headers["accept"]).toBe("application/json");
3243
+ expect17(data.headers["accept-language"]).toBe("en-US,en;q=0.9");
3244
+ expect17(data.headers["cache-control"]).toBe("no-cache");
3245
+ expect17(data.headers["user-agent"]).toBeTruthy();
3246
+ expect17(data.headers["x-request-id"]).toBe("12345");
3133
3247
  });
3134
- test16("should handle empty and special URL paths", async (c) => {
3248
+ test17("should handle empty and special URL paths", async (c) => {
3135
3249
  const { client } = await setupDriverTest(c, driverTestConfig);
3136
3250
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3137
3251
  const rootResponse = await actor2.fetch("");
3138
- expect16(rootResponse.ok).toBe(true);
3252
+ expect17(rootResponse.ok).toBe(true);
3139
3253
  const rootData = await rootResponse.json();
3140
- expect16(rootData.pathname).toBe("/");
3254
+ expect17(rootData.pathname).toBe("/");
3141
3255
  const specialResponse = await actor2.fetch(
3142
3256
  "test/path%20with%20spaces/and%2Fslashes"
3143
3257
  );
3144
- expect16(specialResponse.ok).toBe(true);
3258
+ expect17(specialResponse.ok).toBe(true);
3145
3259
  const specialData = await specialResponse.json();
3146
- expect16(specialData.pathname).toMatch(/path.*with.*spaces.*and.*slashes/);
3260
+ expect17(specialData.pathname).toMatch(/path.*with.*spaces.*and.*slashes/);
3147
3261
  const fragmentResponse = await actor2.fetch("test/path#fragment");
3148
- expect16(fragmentResponse.ok).toBe(true);
3262
+ expect17(fragmentResponse.ok).toBe(true);
3149
3263
  const fragmentData = await fragmentResponse.json();
3150
- expect16(fragmentData.pathname).toBe("/test/path");
3151
- expect16(fragmentData.hash).toBe("");
3264
+ expect17(fragmentData.pathname).toBe("/test/path");
3265
+ expect17(fragmentData.hash).toBe("");
3152
3266
  });
3153
- test16("should handle request properties for all HTTP methods", async (c) => {
3267
+ test17("should handle request properties for all HTTP methods", async (c) => {
3154
3268
  const { client } = await setupDriverTest(c, driverTestConfig);
3155
3269
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3156
3270
  const methods = [
@@ -3169,33 +3283,33 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3169
3283
  body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
3170
3284
  });
3171
3285
  if (method === "HEAD") {
3172
- expect16(response.status).toBe(200);
3286
+ expect17(response.status).toBe(200);
3173
3287
  const text = await response.text();
3174
- expect16(text).toBe("");
3288
+ expect17(text).toBe("");
3175
3289
  } else if (method === "OPTIONS") {
3176
- expect16(response.status).toBe(204);
3290
+ expect17(response.status).toBe(204);
3177
3291
  const text = await response.text();
3178
- expect16(text).toBe("");
3292
+ expect17(text).toBe("");
3179
3293
  } else {
3180
- expect16(response.ok).toBe(true);
3294
+ expect17(response.ok).toBe(true);
3181
3295
  const data = await response.json();
3182
- expect16(data.method).toBe(method);
3296
+ expect17(data.method).toBe(method);
3183
3297
  }
3184
3298
  }
3185
3299
  });
3186
- test16("should handle complex query parameters", async (c) => {
3300
+ test17("should handle complex query parameters", async (c) => {
3187
3301
  const { client } = await setupDriverTest(c, driverTestConfig);
3188
3302
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3189
3303
  const response = await actor2.fetch(
3190
3304
  "test?key=value1&key=value2&array[]=1&array[]=2&nested[prop]=val"
3191
3305
  );
3192
- expect16(response.ok).toBe(true);
3306
+ expect17(response.ok).toBe(true);
3193
3307
  const data = await response.json();
3194
- expect16(data.searchParams.key).toBe("value2");
3195
- expect16(data.searchParams["array[]"]).toBe("2");
3196
- expect16(data.searchParams["nested[prop]"]).toBe("val");
3308
+ expect17(data.searchParams.key).toBe("value2");
3309
+ expect17(data.searchParams["array[]"]).toBe("2");
3310
+ expect17(data.searchParams["nested[prop]"]).toBe("val");
3197
3311
  });
3198
- test16("should handle multipart form data", async (c) => {
3312
+ test17("should handle multipart form data", async (c) => {
3199
3313
  const { client } = await setupDriverTest(c, driverTestConfig);
3200
3314
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3201
3315
  const boundary = "----RivetKitBoundary";
@@ -3217,23 +3331,23 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3217
3331
  },
3218
3332
  body
3219
3333
  });
3220
- expect16(response.ok).toBe(true);
3334
+ expect17(response.ok).toBe(true);
3221
3335
  const data = await response.json();
3222
- expect16(data.headers["content-type"]).toContain("multipart/form-data");
3223
- expect16(data.bodyText).toContain("field1");
3224
- expect16(data.bodyText).toContain("value1");
3336
+ expect17(data.headers["content-type"]).toContain("multipart/form-data");
3337
+ expect17(data.bodyText).toContain("field1");
3338
+ expect17(data.bodyText).toContain("value1");
3225
3339
  });
3226
- test16("should handle very long URLs", async (c) => {
3340
+ test17("should handle very long URLs", async (c) => {
3227
3341
  const { client } = await setupDriverTest(c, driverTestConfig);
3228
3342
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3229
3343
  const longValue = "x".repeat(1e3);
3230
3344
  const response = await actor2.fetch(`test/long?param=${longValue}`);
3231
- expect16(response.ok).toBe(true);
3345
+ expect17(response.ok).toBe(true);
3232
3346
  const data = await response.json();
3233
- expect16(data.searchParams.param).toBe(longValue);
3234
- expect16(data.search.length).toBeGreaterThan(1e3);
3347
+ expect17(data.searchParams.param).toBe(longValue);
3348
+ expect17(data.search.length).toBeGreaterThan(1e3);
3235
3349
  });
3236
- test16("should handle large request bodies", async (c) => {
3350
+ test17("should handle large request bodies", async (c) => {
3237
3351
  const { client } = await setupDriverTest(c, driverTestConfig);
3238
3352
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3239
3353
  const largeArray = new Array(1e4).fill({
@@ -3248,22 +3362,22 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3248
3362
  },
3249
3363
  body: JSON.stringify(largeArray)
3250
3364
  });
3251
- expect16(response.ok).toBe(true);
3365
+ expect17(response.ok).toBe(true);
3252
3366
  const data = await response.json();
3253
- expect16(data.body).toHaveLength(1e4);
3367
+ expect17(data.body).toHaveLength(1e4);
3254
3368
  });
3255
- test16("should handle missing content-type header", async (c) => {
3369
+ test17("should handle missing content-type header", async (c) => {
3256
3370
  const { client } = await setupDriverTest(c, driverTestConfig);
3257
3371
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3258
3372
  const response = await actor2.fetch("test/no-content-type", {
3259
3373
  method: "POST",
3260
3374
  body: "plain text without content-type"
3261
3375
  });
3262
- expect16(response.ok).toBe(true);
3376
+ expect17(response.ok).toBe(true);
3263
3377
  const data = await response.json();
3264
- expect16(data.bodyText).toBe("plain text without content-type");
3378
+ expect17(data.bodyText).toBe("plain text without content-type");
3265
3379
  });
3266
- test16("should handle empty request body", async (c) => {
3380
+ test17("should handle empty request body", async (c) => {
3267
3381
  const { client } = await setupDriverTest(c, driverTestConfig);
3268
3382
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3269
3383
  const response = await actor2.fetch("test/empty", {
@@ -3273,12 +3387,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3273
3387
  },
3274
3388
  body: ""
3275
3389
  });
3276
- expect16(response.ok).toBe(true);
3390
+ expect17(response.ok).toBe(true);
3277
3391
  const data = await response.json();
3278
- expect16(data.body).toBeNull();
3279
- expect16(data.bodyText).toBe("");
3392
+ expect17(data.body).toBeNull();
3393
+ expect17(data.bodyText).toBe("");
3280
3394
  });
3281
- test16("should handle custom HTTP methods", async (c) => {
3395
+ test17("should handle custom HTTP methods", async (c) => {
3282
3396
  const { client } = await setupDriverTest(c, driverTestConfig);
3283
3397
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3284
3398
  try {
@@ -3287,12 +3401,12 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3287
3401
  });
3288
3402
  if (response.ok) {
3289
3403
  const data = await response.json();
3290
- expect16(data.method).toBe("CUSTOM");
3404
+ expect17(data.method).toBe("CUSTOM");
3291
3405
  }
3292
3406
  } catch (error) {
3293
3407
  }
3294
3408
  });
3295
- test16("should handle cookies in headers", async (c) => {
3409
+ test17("should handle cookies in headers", async (c) => {
3296
3410
  const { client } = await setupDriverTest(c, driverTestConfig);
3297
3411
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3298
3412
  const response = await actor2.fetch("test/cookies", {
@@ -3300,25 +3414,25 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3300
3414
  Cookie: "session=abc123; user=test; preferences=dark_mode"
3301
3415
  }
3302
3416
  });
3303
- expect16(response.ok).toBe(true);
3417
+ expect17(response.ok).toBe(true);
3304
3418
  const data = await response.json();
3305
- expect16(data.headers.cookie).toBe(
3419
+ expect17(data.headers.cookie).toBe(
3306
3420
  "session=abc123; user=test; preferences=dark_mode"
3307
3421
  );
3308
3422
  });
3309
- test16("should handle URL encoding properly", async (c) => {
3423
+ test17("should handle URL encoding properly", async (c) => {
3310
3424
  const { client } = await setupDriverTest(c, driverTestConfig);
3311
3425
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3312
3426
  const response = await actor2.fetch(
3313
3427
  "test/encoded?special=%20%21%40%23%24%25%5E%26&unicode=%E2%9C%93&email=test%40example.com"
3314
3428
  );
3315
- expect16(response.ok).toBe(true);
3429
+ expect17(response.ok).toBe(true);
3316
3430
  const data = await response.json();
3317
- expect16(data.searchParams.special).toBe(" !@#$%^&");
3318
- expect16(data.searchParams.unicode).toBe("\u2713");
3319
- expect16(data.searchParams.email).toBe("test@example.com");
3431
+ expect17(data.searchParams.special).toBe(" !@#$%^&");
3432
+ expect17(data.searchParams.unicode).toBe("\u2713");
3433
+ expect17(data.searchParams.email).toBe("test@example.com");
3320
3434
  });
3321
- test16("should handle concurrent requests maintaining separate contexts", async (c) => {
3435
+ test17("should handle concurrent requests maintaining separate contexts", async (c) => {
3322
3436
  const { client } = await setupDriverTest(c, driverTestConfig);
3323
3437
  const actor2 = client.rawHttpRequestPropertiesActor.getOrCreate(["test"]);
3324
3438
  const requests = [
@@ -3340,24 +3454,24 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
3340
3454
  const results = await Promise.all(
3341
3455
  responses.map((r) => r.json())
3342
3456
  );
3343
- expect16(results[0].searchParams.id).toBe("1");
3344
- expect16(results[0].method).toBe("POST");
3345
- expect16(results[0].body).toEqual({ request: 1 });
3346
- expect16(results[1].searchParams.id).toBe("2");
3347
- expect16(results[1].method).toBe("PUT");
3348
- expect16(results[1].body).toEqual({ request: 2 });
3349
- expect16(results[2].searchParams.id).toBe("3");
3350
- expect16(results[2].method).toBe("DELETE");
3351
- expect16(results[2].body).toBeNull();
3457
+ expect17(results[0].searchParams.id).toBe("1");
3458
+ expect17(results[0].method).toBe("POST");
3459
+ expect17(results[0].body).toEqual({ request: 1 });
3460
+ expect17(results[1].searchParams.id).toBe("2");
3461
+ expect17(results[1].method).toBe("PUT");
3462
+ expect17(results[1].body).toEqual({ request: 2 });
3463
+ expect17(results[2].searchParams.id).toBe("3");
3464
+ expect17(results[2].method).toBe("DELETE");
3465
+ expect17(results[2].body).toBeNull();
3352
3466
  });
3353
3467
  });
3354
3468
  }
3355
3469
 
3356
3470
  // src/driver-test-suite/tests/raw-websocket.ts
3357
- import { describe as describe18, expect as expect17, test as test17 } from "vitest";
3471
+ import { describe as describe19, expect as expect18, test as test18 } from "vitest";
3358
3472
  function runRawWebSocketTests(driverTestConfig) {
3359
- describe18("raw websocket", () => {
3360
- test17("should establish raw WebSocket connection", async (c) => {
3473
+ describe19("raw websocket", () => {
3474
+ test18("should establish raw WebSocket connection", async (c) => {
3361
3475
  const { client } = await setupDriverTest(c, driverTestConfig);
3362
3476
  const actor2 = client.rawWebSocketActor.getOrCreate(["basic"]);
3363
3477
  const ws = await actor2.websocket();
@@ -3384,11 +3498,11 @@ function runRawWebSocketTests(driverTestConfig) {
3384
3498
  );
3385
3499
  ws.addEventListener("close", reject);
3386
3500
  });
3387
- expect17(welcomeMessage.type).toBe("welcome");
3388
- expect17(welcomeMessage.connectionCount).toBe(1);
3501
+ expect18(welcomeMessage.type).toBe("welcome");
3502
+ expect18(welcomeMessage.connectionCount).toBe(1);
3389
3503
  ws.close();
3390
3504
  });
3391
- test17("should echo messages", async (c) => {
3505
+ test18("should echo messages", async (c) => {
3392
3506
  const { client } = await setupDriverTest(c, driverTestConfig);
3393
3507
  const actor2 = client.rawWebSocketActor.getOrCreate(["echo"]);
3394
3508
  const ws = await actor2.websocket();
@@ -3414,10 +3528,10 @@ function runRawWebSocketTests(driverTestConfig) {
3414
3528
  );
3415
3529
  ws.addEventListener("close", reject);
3416
3530
  });
3417
- expect17(echoMessage).toEqual(testMessage);
3531
+ expect18(echoMessage).toEqual(testMessage);
3418
3532
  ws.close();
3419
3533
  });
3420
- test17("should handle ping/pong protocol", async (c) => {
3534
+ test18("should handle ping/pong protocol", async (c) => {
3421
3535
  const { client } = await setupDriverTest(c, driverTestConfig);
3422
3536
  const actor2 = client.rawWebSocketActor.getOrCreate(["ping"]);
3423
3537
  const ws = await actor2.websocket();
@@ -3441,11 +3555,11 @@ function runRawWebSocketTests(driverTestConfig) {
3441
3555
  });
3442
3556
  ws.addEventListener("close", reject);
3443
3557
  });
3444
- expect17(pongMessage.type).toBe("pong");
3445
- expect17(pongMessage.timestamp).toBeDefined();
3558
+ expect18(pongMessage.type).toBe("pong");
3559
+ expect18(pongMessage.timestamp).toBeDefined();
3446
3560
  ws.close();
3447
3561
  });
3448
- test17("should track stats across connections", async (c) => {
3562
+ test18("should track stats across connections", async (c) => {
3449
3563
  const { client } = await setupDriverTest(c, driverTestConfig);
3450
3564
  const actor1 = client.rawWebSocketActor.getOrCreate(["stats"]);
3451
3565
  const ws1 = await actor1.websocket();
@@ -3485,15 +3599,15 @@ function runRawWebSocketTests(driverTestConfig) {
3485
3599
  });
3486
3600
  ws1.send(JSON.stringify({ type: "getStats" }));
3487
3601
  const stats = await statsPromise;
3488
- expect17(stats.connectionCount).toBe(2);
3489
- expect17(stats.messageCount).toBe(4);
3602
+ expect18(stats.connectionCount).toBe(2);
3603
+ expect18(stats.messageCount).toBe(4);
3490
3604
  const actionStats = await actor1.getStats();
3491
- expect17(actionStats.connectionCount).toBe(2);
3492
- expect17(actionStats.messageCount).toBe(4);
3605
+ expect18(actionStats.connectionCount).toBe(2);
3606
+ expect18(actionStats.messageCount).toBe(4);
3493
3607
  ws1.close();
3494
3608
  ws2.close();
3495
3609
  });
3496
- test17("should handle binary data", async (c) => {
3610
+ test18("should handle binary data", async (c) => {
3497
3611
  const { client } = await setupDriverTest(c, driverTestConfig);
3498
3612
  const actor2 = client.rawWebSocketBinaryActor.getOrCreate(["binary"]);
3499
3613
  const ws = await actor2.websocket();
@@ -3522,7 +3636,7 @@ function runRawWebSocketTests(driverTestConfig) {
3522
3636
  const smallData = new Uint8Array([1, 2, 3, 4, 5]);
3523
3637
  ws.send(smallData);
3524
3638
  const smallReversed = await receiveBinaryMessage();
3525
- expect17(Array.from(smallReversed)).toEqual([5, 4, 3, 2, 1]);
3639
+ expect18(Array.from(smallReversed)).toEqual([5, 4, 3, 2, 1]);
3526
3640
  const largeData = new Uint8Array(1024);
3527
3641
  for (let i = 0; i < largeData.length; i++) {
3528
3642
  largeData[i] = i % 256;
@@ -3530,11 +3644,11 @@ function runRawWebSocketTests(driverTestConfig) {
3530
3644
  ws.send(largeData);
3531
3645
  const largeReversed = await receiveBinaryMessage();
3532
3646
  for (let i = 0; i < largeData.length; i++) {
3533
- expect17(largeReversed[i]).toBe(largeData[largeData.length - 1 - i]);
3647
+ expect18(largeReversed[i]).toBe(largeData[largeData.length - 1 - i]);
3534
3648
  }
3535
3649
  ws.close();
3536
3650
  });
3537
- test17("should work with custom paths", async (c) => {
3651
+ test18("should work with custom paths", async (c) => {
3538
3652
  const { client } = await setupDriverTest(c, driverTestConfig);
3539
3653
  const actor2 = client.rawWebSocketActor.getOrCreate(["paths"]);
3540
3654
  const ws = await actor2.websocket("custom/path");
@@ -3554,33 +3668,10 @@ function runRawWebSocketTests(driverTestConfig) {
3554
3668
  { once: true }
3555
3669
  );
3556
3670
  });
3557
- expect17(welcomeMessage.type).toBe("welcome");
3558
- ws.close();
3559
- });
3560
- test17("should pass connection parameters through subprotocols", async (c) => {
3561
- const { client } = await setupDriverTest(c, driverTestConfig);
3562
- const testParams = { userId: "test123", role: "admin" };
3563
- const actor2 = client.rawWebSocketActor.getOrCreate(["params"], {
3564
- params: testParams
3565
- });
3566
- const ws = await actor2.websocket();
3567
- await new Promise((resolve) => {
3568
- ws.addEventListener("open", () => resolve(), { once: true });
3569
- });
3570
- ws.send(JSON.stringify({ type: "getAuthData" }));
3571
- const response = await new Promise((resolve, reject) => {
3572
- ws.addEventListener("message", (event) => {
3573
- const data = JSON.parse(event.data);
3574
- if (data.type === "authData") {
3575
- resolve(data);
3576
- }
3577
- });
3578
- ws.addEventListener("close", reject);
3579
- });
3580
- expect17(response).toBeDefined();
3671
+ expect18(welcomeMessage.type).toBe("welcome");
3581
3672
  ws.close();
3582
3673
  });
3583
- test17("should handle connection close properly", async (c) => {
3674
+ test18("should handle connection close properly", async (c) => {
3584
3675
  const { client } = await setupDriverTest(c, driverTestConfig);
3585
3676
  const actor2 = client.rawWebSocketActor.getOrCreate(["close-test"]);
3586
3677
  const ws = await actor2.websocket();
@@ -3591,7 +3682,7 @@ function runRawWebSocketTests(driverTestConfig) {
3591
3682
  });
3592
3683
  }
3593
3684
  const initialStats = await actor2.getStats();
3594
- expect17(initialStats.connectionCount).toBe(1);
3685
+ expect18(initialStats.connectionCount).toBe(1);
3595
3686
  const closePromise = new Promise((resolve) => {
3596
3687
  ws.addEventListener("close", () => resolve(), { once: true });
3597
3688
  });
@@ -3605,9 +3696,9 @@ function runRawWebSocketTests(driverTestConfig) {
3605
3696
  }
3606
3697
  await new Promise((resolve) => setTimeout(resolve, 50));
3607
3698
  }
3608
- expect17(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3699
+ expect18(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3609
3700
  });
3610
- test17("should properly handle onWebSocket open and close events", async (c) => {
3701
+ test18("should properly handle onWebSocket open and close events", async (c) => {
3611
3702
  const { client } = await setupDriverTest(c, driverTestConfig);
3612
3703
  const actor2 = client.rawWebSocketActor.getOrCreate(["open-close-test"]);
3613
3704
  const ws1 = await actor2.websocket();
@@ -3625,8 +3716,8 @@ function runRawWebSocketTests(driverTestConfig) {
3625
3716
  );
3626
3717
  ws1.addEventListener("close", reject);
3627
3718
  });
3628
- expect17(welcome1.type).toBe("welcome");
3629
- expect17(welcome1.connectionCount).toBe(1);
3719
+ expect18(welcome1.type).toBe("welcome");
3720
+ expect18(welcome1.connectionCount).toBe(1);
3630
3721
  const ws2 = await actor2.websocket();
3631
3722
  await new Promise((resolve, reject) => {
3632
3723
  ws2.addEventListener("open", () => resolve(), { once: true });
@@ -3642,10 +3733,10 @@ function runRawWebSocketTests(driverTestConfig) {
3642
3733
  );
3643
3734
  ws2.addEventListener("close", reject);
3644
3735
  });
3645
- expect17(welcome2.type).toBe("welcome");
3646
- expect17(welcome2.connectionCount).toBe(2);
3736
+ expect18(welcome2.type).toBe("welcome");
3737
+ expect18(welcome2.connectionCount).toBe(2);
3647
3738
  const midStats = await actor2.getStats();
3648
- expect17(midStats.connectionCount).toBe(2);
3739
+ expect18(midStats.connectionCount).toBe(2);
3649
3740
  ws1.close();
3650
3741
  await new Promise((resolve) => {
3651
3742
  ws1.addEventListener("close", () => resolve(), { once: true });
@@ -3658,7 +3749,7 @@ function runRawWebSocketTests(driverTestConfig) {
3658
3749
  }
3659
3750
  await new Promise((resolve) => setTimeout(resolve, 50));
3660
3751
  }
3661
- expect17(afterFirstClose == null ? void 0 : afterFirstClose.connectionCount).toBe(1);
3752
+ expect18(afterFirstClose == null ? void 0 : afterFirstClose.connectionCount).toBe(1);
3662
3753
  ws2.close();
3663
3754
  await new Promise((resolve) => {
3664
3755
  ws2.addEventListener("close", () => resolve(), { once: true });
@@ -3671,9 +3762,9 @@ function runRawWebSocketTests(driverTestConfig) {
3671
3762
  }
3672
3763
  await new Promise((resolve) => setTimeout(resolve, 50));
3673
3764
  }
3674
- expect17(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3765
+ expect18(finalStats == null ? void 0 : finalStats.connectionCount).toBe(0);
3675
3766
  });
3676
- test17("should handle query parameters in websocket paths", async (c) => {
3767
+ test18("should handle query parameters in websocket paths", async (c) => {
3677
3768
  const { client } = await setupDriverTest(c, driverTestConfig);
3678
3769
  const actor2 = client.rawWebSocketActor.getOrCreate(["query-params"]);
3679
3770
  const ws = await actor2.websocket("api/v1/stream?token=abc123&user=test");
@@ -3692,19 +3783,19 @@ function runRawWebSocketTests(driverTestConfig) {
3692
3783
  });
3693
3784
  ws.send(JSON.stringify({ type: "getRequestInfo" }));
3694
3785
  const requestInfo = await requestInfoPromise;
3695
- expect17(requestInfo.url).toContain("api/v1/stream");
3696
- expect17(requestInfo.url).toContain("token=abc123");
3697
- expect17(requestInfo.url).toContain("user=test");
3786
+ expect18(requestInfo.url).toContain("api/v1/stream");
3787
+ expect18(requestInfo.url).toContain("token=abc123");
3788
+ expect18(requestInfo.url).toContain("user=test");
3698
3789
  ws.close();
3699
3790
  });
3700
3791
  });
3701
3792
  }
3702
3793
 
3703
3794
  // src/driver-test-suite/tests/request-access.ts
3704
- import { describe as describe19, expect as expect18, test as test18 } from "vitest";
3795
+ import { describe as describe20, expect as expect19, test as test19 } from "vitest";
3705
3796
  function runRequestAccessTests(driverTestConfig) {
3706
- describe19("Request Access in Lifecycle Hooks", () => {
3707
- test18("should have access to request object in onBeforeConnect and createConnState", async (c) => {
3797
+ describe20("Request Access in Lifecycle Hooks", () => {
3798
+ test19("should have access to request object in onBeforeConnect and createConnState", async (c) => {
3708
3799
  const { client } = await setupDriverTest(c, driverTestConfig);
3709
3800
  const handle = client.requestAccessActor.getOrCreate(["test-request"], {
3710
3801
  params: { trackRequest: true }
@@ -3712,19 +3803,19 @@ function runRequestAccessTests(driverTestConfig) {
3712
3803
  const connection = handle.connect();
3713
3804
  const requestInfo = await connection.getRequestInfo();
3714
3805
  if (driverTestConfig.clientType === "http") {
3715
- expect18(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3716
- expect18(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
3717
- expect18(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
3718
- expect18(requestInfo.onBeforeConnect.requestHeaders).toBeDefined();
3719
- expect18(requestInfo.createConnState.hasRequest).toBe(true);
3720
- expect18(requestInfo.createConnState.requestUrl).toBeDefined();
3721
- expect18(requestInfo.createConnState.requestMethod).toBeDefined();
3722
- expect18(requestInfo.createConnState.requestHeaders).toBeDefined();
3806
+ expect19(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3807
+ expect19(requestInfo.onBeforeConnect.requestUrl).toBeDefined();
3808
+ expect19(requestInfo.onBeforeConnect.requestMethod).toBeDefined();
3809
+ expect19(requestInfo.onBeforeConnect.requestHeaders).toBeDefined();
3810
+ expect19(requestInfo.createConnState.hasRequest).toBe(true);
3811
+ expect19(requestInfo.createConnState.requestUrl).toBeDefined();
3812
+ expect19(requestInfo.createConnState.requestMethod).toBeDefined();
3813
+ expect19(requestInfo.createConnState.requestHeaders).toBeDefined();
3723
3814
  } else {
3724
3815
  }
3725
3816
  await connection.dispose();
3726
3817
  });
3727
- test18("should not have request when trackRequest is false", async (c) => {
3818
+ test19("should not have request when trackRequest is false", async (c) => {
3728
3819
  const { client } = await setupDriverTest(c, driverTestConfig);
3729
3820
  const handle = client.requestAccessActor.getOrCreate(
3730
3821
  ["test-no-request"],
@@ -3734,21 +3825,21 @@ function runRequestAccessTests(driverTestConfig) {
3734
3825
  );
3735
3826
  const connection = handle.connect();
3736
3827
  const requestInfo = await connection.getRequestInfo();
3737
- expect18(requestInfo.onBeforeConnect.hasRequest).toBe(false);
3738
- expect18(requestInfo.onBeforeConnect.requestUrl).toBeNull();
3739
- expect18(requestInfo.onBeforeConnect.requestMethod).toBeNull();
3740
- expect18(
3828
+ expect19(requestInfo.onBeforeConnect.hasRequest).toBe(false);
3829
+ expect19(requestInfo.onBeforeConnect.requestUrl).toBeNull();
3830
+ expect19(requestInfo.onBeforeConnect.requestMethod).toBeNull();
3831
+ expect19(
3741
3832
  Object.keys(requestInfo.onBeforeConnect.requestHeaders)
3742
3833
  ).toHaveLength(0);
3743
- expect18(requestInfo.createConnState.hasRequest).toBe(false);
3744
- expect18(requestInfo.createConnState.requestUrl).toBeNull();
3745
- expect18(requestInfo.createConnState.requestMethod).toBeNull();
3746
- expect18(
3834
+ expect19(requestInfo.createConnState.hasRequest).toBe(false);
3835
+ expect19(requestInfo.createConnState.requestUrl).toBeNull();
3836
+ expect19(requestInfo.createConnState.requestMethod).toBeNull();
3837
+ expect19(
3747
3838
  Object.keys(requestInfo.createConnState.requestHeaders)
3748
3839
  ).toHaveLength(0);
3749
3840
  await connection.dispose();
3750
3841
  });
3751
- test18("should capture request headers and method", async (c) => {
3842
+ test19("should capture request headers and method", async (c) => {
3752
3843
  const { client } = await setupDriverTest(c, driverTestConfig);
3753
3844
  const handle = client.requestAccessActor.getOrCreate(["test-headers"], {
3754
3845
  params: { trackRequest: true }
@@ -3756,18 +3847,18 @@ function runRequestAccessTests(driverTestConfig) {
3756
3847
  const connection = handle.connect();
3757
3848
  const requestInfo = await connection.getRequestInfo();
3758
3849
  if (driverTestConfig.clientType === "http") {
3759
- expect18(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3760
- expect18(requestInfo.onBeforeConnect.requestMethod).toBeTruthy();
3761
- expect18(requestInfo.onBeforeConnect.requestUrl).toBeTruthy();
3762
- expect18(requestInfo.onBeforeConnect.requestHeaders).toBeTruthy();
3763
- expect18(typeof requestInfo.onBeforeConnect.requestHeaders).toBe(
3850
+ expect19(requestInfo.onBeforeConnect.hasRequest).toBe(true);
3851
+ expect19(requestInfo.onBeforeConnect.requestMethod).toBeTruthy();
3852
+ expect19(requestInfo.onBeforeConnect.requestUrl).toBeTruthy();
3853
+ expect19(requestInfo.onBeforeConnect.requestHeaders).toBeTruthy();
3854
+ expect19(typeof requestInfo.onBeforeConnect.requestHeaders).toBe(
3764
3855
  "object"
3765
3856
  );
3766
- expect18(requestInfo.createConnState.hasRequest).toBe(true);
3767
- expect18(requestInfo.createConnState.requestMethod).toBeTruthy();
3768
- expect18(requestInfo.createConnState.requestUrl).toBeTruthy();
3769
- expect18(requestInfo.createConnState.requestHeaders).toBeTruthy();
3770
- expect18(typeof requestInfo.createConnState.requestHeaders).toBe(
3857
+ expect19(requestInfo.createConnState.hasRequest).toBe(true);
3858
+ expect19(requestInfo.createConnState.requestMethod).toBeTruthy();
3859
+ expect19(requestInfo.createConnState.requestUrl).toBeTruthy();
3860
+ expect19(requestInfo.createConnState.requestHeaders).toBeTruthy();
3861
+ expect19(typeof requestInfo.createConnState.requestHeaders).toBe(
3771
3862
  "object"
3772
3863
  );
3773
3864
  } else {
@@ -3784,16 +3875,19 @@ function runDriverTests(driverTestConfigPartial) {
3784
3875
  ...driverTestConfigPartial,
3785
3876
  clientType
3786
3877
  };
3787
- describe20(`client type (${clientType})`, () => {
3878
+ describe21(`client type (${clientType})`, () => {
3879
+ var _a;
3788
3880
  runActorDriverTests(driverTestConfig);
3789
3881
  runManagerDriverTests(driverTestConfig);
3790
- for (const transport of ["websocket", "sse"]) {
3791
- describe20(`transport (${transport})`, () => {
3882
+ const transports = ((_a = driverTestConfig.skip) == null ? void 0 : _a.sse) ? ["websocket"] : ["websocket", "sse"];
3883
+ for (const transport of transports) {
3884
+ describe21(`transport (${transport})`, () => {
3792
3885
  runActorConnTests({
3793
3886
  ...driverTestConfig,
3794
3887
  transport
3795
3888
  });
3796
3889
  runActorConnStateTests({ ...driverTestConfig, transport });
3890
+ runActorReconnectTests({ ...driverTestConfig, transport });
3797
3891
  runRequestAccessTests({ ...driverTestConfig, transport });
3798
3892
  runActorDriverTestsWithTransport({ ...driverTestConfig, transport });
3799
3893
  });
@@ -3845,11 +3939,12 @@ async function createTestRuntime(registryPath, driverFactory) {
3845
3939
  }
3846
3940
  });
3847
3941
  const managerDriver = driver.manager(registry.config, config);
3942
+ configureInspectorAccessToken(config, managerDriver);
3848
3943
  const { router } = createManagerRouter(
3849
3944
  registry.config,
3850
3945
  config,
3851
3946
  managerDriver,
3852
- false
3947
+ void 0
3853
3948
  );
3854
3949
  const nodeWebSocket = createNodeWebSocket({ app: router });
3855
3950
  upgradeWebSocket = nodeWebSocket.upgradeWebSocket;
@@ -3859,7 +3954,7 @@ async function createTestRuntime(registryPath, driverFactory) {
3859
3954
  hostname: "127.0.0.1",
3860
3955
  port
3861
3956
  });
3862
- invariant2(
3957
+ invariant(
3863
3958
  nodeWebSocket.injectWebSocket !== void 0,
3864
3959
  "should have injectWebSocket"
3865
3960
  );