rivetkit 2.1.2 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/browser/client.d.ts +11 -0
  2. package/dist/browser/client.js +1 -1
  3. package/dist/browser/client.js.map +1 -1
  4. package/dist/browser/inspector/client.js +1 -1
  5. package/dist/browser/inspector/client.js.map +1 -1
  6. package/dist/inspector.tar.gz +0 -0
  7. package/dist/tsup/{chunk-MNS5LY6M.cjs → chunk-3B6PCYJB.cjs} +280 -115
  8. package/dist/tsup/chunk-3B6PCYJB.cjs.map +1 -0
  9. package/dist/tsup/{chunk-YQ5P6KMN.js → chunk-3GTO6H3E.js} +12 -5
  10. package/dist/tsup/chunk-3GTO6H3E.js.map +1 -0
  11. package/dist/tsup/{chunk-RMJJE43B.cjs → chunk-4KSHPFXF.cjs} +2 -2
  12. package/dist/tsup/{chunk-RMJJE43B.cjs.map → chunk-4KSHPFXF.cjs.map} +1 -1
  13. package/dist/tsup/{chunk-PW3YONDJ.js → chunk-5UEFNG7P.js} +2 -2
  14. package/dist/tsup/{chunk-PSUVV4HM.js → chunk-ANKZ2FS6.js} +2 -4
  15. package/dist/tsup/chunk-ANKZ2FS6.js.map +1 -0
  16. package/dist/tsup/{chunk-GVQAVU7R.cjs → chunk-AQD4CBZ2.cjs} +4 -4
  17. package/dist/tsup/{chunk-GVQAVU7R.cjs.map → chunk-AQD4CBZ2.cjs.map} +1 -1
  18. package/dist/tsup/{chunk-WUXR722E.js → chunk-DZXDUGLL.js} +2 -2
  19. package/dist/tsup/{chunk-WUXR722E.js.map → chunk-DZXDUGLL.js.map} +1 -1
  20. package/dist/tsup/{chunk-NXEHFUDB.cjs → chunk-GXRVSSVD.cjs} +28 -21
  21. package/dist/tsup/chunk-GXRVSSVD.cjs.map +1 -0
  22. package/dist/tsup/{chunk-UZV7NXC6.cjs → chunk-H5TSEPN4.cjs} +30 -30
  23. package/dist/tsup/{chunk-UZV7NXC6.cjs.map → chunk-H5TSEPN4.cjs.map} +1 -1
  24. package/dist/tsup/{chunk-TDFDR7AO.js → chunk-HBYEYBIC.js} +2 -2
  25. package/dist/tsup/{chunk-772NPMTY.cjs → chunk-HKOSZKKZ.cjs} +263 -299
  26. package/dist/tsup/chunk-HKOSZKKZ.cjs.map +1 -0
  27. package/dist/tsup/{chunk-HB4RGGMC.js → chunk-I6PL6QIY.js} +5 -5
  28. package/dist/tsup/{chunk-RHUII57M.js → chunk-KTWY3K6Z.js} +23 -12
  29. package/dist/tsup/chunk-KTWY3K6Z.js.map +1 -0
  30. package/dist/tsup/{chunk-HFWRHT5T.cjs → chunk-LK36OGGO.cjs} +3 -5
  31. package/dist/tsup/chunk-LK36OGGO.cjs.map +1 -0
  32. package/dist/tsup/{chunk-BSIJG3LG.js → chunk-M6H4XIF4.js} +179 -215
  33. package/dist/tsup/chunk-M6H4XIF4.js.map +1 -0
  34. package/dist/tsup/{chunk-ZHQDRRMY.cjs → chunk-QPADHLDU.cjs} +3 -3
  35. package/dist/tsup/{chunk-ZHQDRRMY.cjs.map → chunk-QPADHLDU.cjs.map} +1 -1
  36. package/dist/tsup/{chunk-BFI4LYS2.js → chunk-TEFYRRAK.js} +4 -4
  37. package/dist/tsup/{chunk-PZAV6PP2.cjs → chunk-TEUL4UYN.cjs} +152 -152
  38. package/dist/tsup/{chunk-PZAV6PP2.cjs.map → chunk-TEUL4UYN.cjs.map} +1 -1
  39. package/dist/tsup/{chunk-VMX4I4MP.js → chunk-UDMRZR6A.js} +212 -47
  40. package/dist/tsup/chunk-UDMRZR6A.js.map +1 -0
  41. package/dist/tsup/{chunk-QABDKI3W.cjs → chunk-UWAGLDT6.cjs} +263 -252
  42. package/dist/tsup/chunk-UWAGLDT6.cjs.map +1 -0
  43. package/dist/tsup/client/mod.cjs +6 -6
  44. package/dist/tsup/client/mod.d.cts +2 -2
  45. package/dist/tsup/client/mod.d.ts +2 -2
  46. package/dist/tsup/client/mod.js +5 -5
  47. package/dist/tsup/common/log.cjs +2 -2
  48. package/dist/tsup/common/log.js +1 -1
  49. package/dist/tsup/common/websocket.cjs +3 -3
  50. package/dist/tsup/common/websocket.js +2 -2
  51. package/dist/tsup/{config-P3XujgRr.d.ts → config-Qj-zLJPc.d.ts} +11 -0
  52. package/dist/tsup/{config-_gfywqqI.d.cts → config-iPj5l1bL.d.cts} +11 -0
  53. package/dist/tsup/{context-uNA4TRn3.d.ts → context-CQCMuHND.d.ts} +1 -1
  54. package/dist/tsup/{context-Bxd8Cx4H.d.cts → context-DzvH1PBK.d.cts} +1 -1
  55. package/dist/tsup/{driver-CPGHKXyh.d.ts → driver-Jo8v-kbU.d.ts} +1 -1
  56. package/dist/tsup/driver-helpers/mod.cjs +4 -4
  57. package/dist/tsup/driver-helpers/mod.d.cts +4 -4
  58. package/dist/tsup/driver-helpers/mod.d.ts +4 -4
  59. package/dist/tsup/driver-helpers/mod.js +3 -3
  60. package/dist/tsup/{driver-BcLvZcKl.d.cts → driver-iV8J-WMv.d.cts} +1 -1
  61. package/dist/tsup/driver-test-suite/mod.cjs +556 -333
  62. package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
  63. package/dist/tsup/driver-test-suite/mod.d.cts +2 -2
  64. package/dist/tsup/driver-test-suite/mod.d.ts +2 -2
  65. package/dist/tsup/driver-test-suite/mod.js +1332 -1109
  66. package/dist/tsup/driver-test-suite/mod.js.map +1 -1
  67. package/dist/tsup/inspector/mod.cjs +3 -3
  68. package/dist/tsup/inspector/mod.js +2 -2
  69. package/dist/tsup/mod.cjs +8 -8
  70. package/dist/tsup/mod.d.cts +5 -5
  71. package/dist/tsup/mod.d.ts +5 -5
  72. package/dist/tsup/mod.js +7 -7
  73. package/dist/tsup/serve-test-suite/mod.cjs +194 -100
  74. package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
  75. package/dist/tsup/serve-test-suite/mod.js +105 -11
  76. package/dist/tsup/serve-test-suite/mod.js.map +1 -1
  77. package/dist/tsup/test/mod.cjs +10 -10
  78. package/dist/tsup/test/mod.d.cts +1 -1
  79. package/dist/tsup/test/mod.d.ts +1 -1
  80. package/dist/tsup/test/mod.js +6 -6
  81. package/dist/tsup/utils.cjs +2 -2
  82. package/dist/tsup/utils.js +1 -1
  83. package/dist/tsup/workflow/mod.cjs +5 -5
  84. package/dist/tsup/workflow/mod.d.cts +3 -3
  85. package/dist/tsup/workflow/mod.d.ts +3 -3
  86. package/dist/tsup/workflow/mod.js +4 -4
  87. package/package.json +5 -5
  88. package/src/actor/config.ts +0 -2
  89. package/src/actor/instance/mod.ts +30 -6
  90. package/src/actor/router.ts +9 -6
  91. package/src/driver-test-suite/mod.ts +3 -0
  92. package/src/driver-test-suite/tests/actor-db.ts +299 -216
  93. package/src/driver-test-suite/tests/actor-driver.ts +4 -0
  94. package/src/driver-test-suite/tests/actor-lifecycle.ts +157 -0
  95. package/src/driver-test-suite/tests/actor-queue.ts +10 -9
  96. package/src/driver-test-suite/tests/actor-workflow.ts +12 -2
  97. package/src/driver-test-suite/tests/conn-error-serialization.ts +64 -0
  98. package/src/driver-test-suite/utils.ts +8 -8
  99. package/src/drivers/engine/actor-driver.ts +113 -11
  100. package/src/manager/router.ts +20 -6
  101. package/src/{registry → utils}/serve.ts +38 -4
  102. package/src/workflow/context.ts +4 -0
  103. package/src/workflow/driver.ts +4 -1
  104. package/dist/tsup/chunk-772NPMTY.cjs.map +0 -1
  105. package/dist/tsup/chunk-BSIJG3LG.js.map +0 -1
  106. package/dist/tsup/chunk-HFWRHT5T.cjs.map +0 -1
  107. package/dist/tsup/chunk-MNS5LY6M.cjs.map +0 -1
  108. package/dist/tsup/chunk-NXEHFUDB.cjs.map +0 -1
  109. package/dist/tsup/chunk-PSUVV4HM.js.map +0 -1
  110. package/dist/tsup/chunk-QABDKI3W.cjs.map +0 -1
  111. package/dist/tsup/chunk-RHUII57M.js.map +0 -1
  112. package/dist/tsup/chunk-VMX4I4MP.js.map +0 -1
  113. package/dist/tsup/chunk-YQ5P6KMN.js.map +0 -1
  114. /package/dist/tsup/{chunk-PW3YONDJ.js.map → chunk-5UEFNG7P.js.map} +0 -0
  115. /package/dist/tsup/{chunk-TDFDR7AO.js.map → chunk-HBYEYBIC.js.map} +0 -0
  116. /package/dist/tsup/{chunk-HB4RGGMC.js.map → chunk-I6PL6QIY.js.map} +0 -0
  117. /package/dist/tsup/{chunk-BFI4LYS2.js.map → chunk-TEFYRRAK.js.map} +0 -0
@@ -4,20 +4,20 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkUZV7NXC6cjs = require('../chunk-UZV7NXC6.cjs');
8
- require('../chunk-NXEHFUDB.cjs');
9
- require('../chunk-GVQAVU7R.cjs');
10
- require('../chunk-772NPMTY.cjs');
11
- require('../chunk-QABDKI3W.cjs');
7
+ var _chunkH5TSEPN4cjs = require('../chunk-H5TSEPN4.cjs');
8
+ require('../chunk-GXRVSSVD.cjs');
9
+ require('../chunk-AQD4CBZ2.cjs');
10
+ require('../chunk-HKOSZKKZ.cjs');
11
+ require('../chunk-UWAGLDT6.cjs');
12
12
 
13
13
 
14
14
 
15
15
 
16
16
 
17
- var _chunkPZAV6PP2cjs = require('../chunk-PZAV6PP2.cjs');
17
+ var _chunkTEUL4UYNcjs = require('../chunk-TEUL4UYN.cjs');
18
18
 
19
19
 
20
- var _chunkZHQDRRMYcjs = require('../chunk-ZHQDRRMY.cjs');
20
+ var _chunkQPADHLDUcjs = require('../chunk-QPADHLDU.cjs');
21
21
  require('../chunk-6LJAZ5R4.cjs');
22
22
  require('../chunk-SR3KQE7Q.cjs');
23
23
 
@@ -29,14 +29,14 @@ require('../chunk-SR3KQE7Q.cjs');
29
29
 
30
30
 
31
31
 
32
- var _chunkMNS5LY6Mcjs = require('../chunk-MNS5LY6M.cjs');
32
+ var _chunk3B6PCYJBcjs = require('../chunk-3B6PCYJB.cjs');
33
33
  require('../chunk-NIYZDWMW.cjs');
34
34
 
35
35
 
36
- var _chunkHFWRHT5Tcjs = require('../chunk-HFWRHT5T.cjs');
36
+ var _chunkLK36OGGOcjs = require('../chunk-LK36OGGO.cjs');
37
37
 
38
38
 
39
- var _chunkRMJJE43Bcjs = require('../chunk-RMJJE43B.cjs');
39
+ var _chunk4KSHPFXFcjs = require('../chunk-4KSHPFXF.cjs');
40
40
 
41
41
 
42
42
 
@@ -85,20 +85,20 @@ function createTestInlineClientDriver(endpoint, encoding) {
85
85
  const oldUrl = new URL(actorRequest.url);
86
86
  const normalizedPath = oldUrl.pathname.startsWith("/") ? oldUrl.pathname.slice(1) : oldUrl.pathname;
87
87
  const pathWithQuery = normalizedPath + oldUrl.search;
88
- _chunkUZV7NXC6cjs.logger.call(void 0, ).debug({
88
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
89
89
  msg: "sending raw http request via test inline driver",
90
90
  actorId,
91
91
  encoding,
92
92
  path: pathWithQuery
93
93
  });
94
94
  const url = `${endpoint}/.test/inline-driver/send-request/${pathWithQuery}`;
95
- _chunkUZV7NXC6cjs.logger.call(void 0, ).debug({
95
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
96
96
  msg: "rewriting http url",
97
97
  from: oldUrl,
98
98
  to: url
99
99
  });
100
100
  const headers = new Headers(actorRequest.headers);
101
- headers.set(_chunkMNS5LY6Mcjs.HEADER_ACTOR_ID, actorId);
101
+ headers.set(_chunk3B6PCYJBcjs.HEADER_ACTOR_ID, actorId);
102
102
  const response = await fetch(
103
103
  new Request(url, {
104
104
  method: actorRequest.method,
@@ -114,7 +114,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
114
114
  const errorData = await clonedResponse.json();
115
115
  if (errorData.error) {
116
116
  if (typeof errorData.error === "object") {
117
- throw new (0, _chunkPZAV6PP2cjs.ActorError)(
117
+ throw new (0, _chunkTEUL4UYNcjs.ActorError)(
118
118
  errorData.error.code,
119
119
  errorData.error.message,
120
120
  errorData.error.metadata
@@ -122,7 +122,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
122
122
  }
123
123
  }
124
124
  } catch (e) {
125
- if (!(e instanceof _chunkPZAV6PP2cjs.ActorError)) {
125
+ if (!(e instanceof _chunkTEUL4UYNcjs.ActorError)) {
126
126
  return response;
127
127
  }
128
128
  throw e;
@@ -131,33 +131,33 @@ function createTestInlineClientDriver(endpoint, encoding) {
131
131
  return response;
132
132
  },
133
133
  async openWebSocket(path, actorId, encoding2, params) {
134
- const WebSocket2 = await _chunkZHQDRRMYcjs.importWebSocket.call(void 0, );
134
+ const WebSocket2 = await _chunkQPADHLDUcjs.importWebSocket.call(void 0, );
135
135
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
136
136
  const wsUrl = new URL(
137
137
  `${endpoint}/.test/inline-driver/connect-websocket/ws`
138
138
  );
139
- _chunkUZV7NXC6cjs.logger.call(void 0, ).debug({
139
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
140
140
  msg: "creating websocket connection via test inline driver",
141
141
  url: wsUrl.toString()
142
142
  });
143
143
  const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
144
144
  const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}`;
145
145
  const protocols = [];
146
- protocols.push(_chunkMNS5LY6Mcjs.WS_PROTOCOL_STANDARD);
147
- protocols.push(`${_chunkMNS5LY6Mcjs.WS_PROTOCOL_TARGET}actor`);
146
+ protocols.push(_chunk3B6PCYJBcjs.WS_PROTOCOL_STANDARD);
147
+ protocols.push(`${_chunk3B6PCYJBcjs.WS_PROTOCOL_TARGET}actor`);
148
148
  protocols.push(
149
- `${_chunkMNS5LY6Mcjs.WS_PROTOCOL_ACTOR}${encodeURIComponent(actorId)}`
149
+ `${_chunk3B6PCYJBcjs.WS_PROTOCOL_ACTOR}${encodeURIComponent(actorId)}`
150
150
  );
151
- protocols.push(`${_chunkMNS5LY6Mcjs.WS_PROTOCOL_ENCODING}${encoding2}`);
151
+ protocols.push(`${_chunk3B6PCYJBcjs.WS_PROTOCOL_ENCODING}${encoding2}`);
152
152
  protocols.push(
153
- `${_chunkMNS5LY6Mcjs.WS_TEST_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
153
+ `${_chunk3B6PCYJBcjs.WS_TEST_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
154
154
  );
155
155
  if (params !== void 0) {
156
156
  protocols.push(
157
- `${_chunkMNS5LY6Mcjs.WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
157
+ `${_chunk3B6PCYJBcjs.WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
158
158
  );
159
159
  }
160
- _chunkUZV7NXC6cjs.logger.call(void 0, ).debug({
160
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
161
161
  msg: "connecting to websocket",
162
162
  url: finalWsUrl,
163
163
  protocols
@@ -177,7 +177,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
177
177
  encoding2,
178
178
  params
179
179
  );
180
- return upgradeWebSocket(() => wsHandler)(c, _chunkRMJJE43Bcjs.noopNext.call(void 0, ));
180
+ return upgradeWebSocket(() => wsHandler)(c, _chunk4KSHPFXFcjs.noopNext.call(void 0, ));
181
181
  },
182
182
  async buildGatewayUrl(actorId) {
183
183
  return `${endpoint}/gateway/${actorId}`;
@@ -194,7 +194,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
194
194
  };
195
195
  }
196
196
  async function makeInlineRequest(endpoint, encoding, method, args) {
197
- _chunkUZV7NXC6cjs.logger.call(void 0, ).debug({
197
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).debug({
198
198
  msg: "sending inline request",
199
199
  encoding,
200
200
  method,
@@ -224,14 +224,14 @@ async function makeInlineRequest(endpoint, encoding, method, args) {
224
224
  if ("ok" in callResponse) {
225
225
  return callResponse.ok;
226
226
  } else if ("err" in callResponse) {
227
- throw new (0, _chunkPZAV6PP2cjs.ActorError)(
227
+ throw new (0, _chunkTEUL4UYNcjs.ActorError)(
228
228
  callResponse.err.group,
229
229
  callResponse.err.code,
230
230
  callResponse.err.message,
231
231
  callResponse.err.metadata
232
232
  );
233
233
  } else {
234
- _chunkHFWRHT5Tcjs.assertUnreachable.call(void 0, callResponse);
234
+ _chunkLK36OGGOcjs.assertUnreachable.call(void 0, callResponse);
235
235
  }
236
236
  }
237
237
 
@@ -243,13 +243,9 @@ async function setupDriverTest(c, driverTestConfig) {
243
243
  _vitest.vi.setSystemTime(FAKE_TIME);
244
244
  }
245
245
  const { endpoint, namespace, runnerName, cleanup } = await driverTestConfig.start();
246
- c.onTestFinished(() => {
247
- _chunkUZV7NXC6cjs.logger.call(void 0, ).info("cleaning up test");
248
- cleanup();
249
- });
250
246
  let client;
251
247
  if (driverTestConfig.clientType === "http") {
252
- client = _chunkPZAV6PP2cjs.createClient.call(void 0, {
248
+ client = _chunkTEUL4UYNcjs.createClient.call(void 0, {
253
249
  endpoint,
254
250
  namespace,
255
251
  runnerName,
@@ -262,16 +258,20 @@ async function setupDriverTest(c, driverTestConfig) {
262
258
  } else if (driverTestConfig.clientType === "inline") {
263
259
  const encoding = _nullishCoalesce(driverTestConfig.encoding, () => ( "bare"));
264
260
  const managerDriver = createTestInlineClientDriver(endpoint, encoding);
265
- const runConfig = _chunkPZAV6PP2cjs.ClientConfigSchema.parse({
261
+ const runConfig = _chunkTEUL4UYNcjs.ClientConfigSchema.parse({
266
262
  encoding
267
263
  });
268
- client = _chunkPZAV6PP2cjs.createClientWithDriver.call(void 0, managerDriver, runConfig);
264
+ client = _chunkTEUL4UYNcjs.createClientWithDriver.call(void 0, managerDriver, runConfig);
269
265
  } else {
270
- _chunkHFWRHT5Tcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
271
- }
272
- if (!driverTestConfig.HACK_skipCleanupNet) {
273
- c.onTestFinished(async () => await client.dispose());
266
+ _chunkLK36OGGOcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
274
267
  }
268
+ c.onTestFinished(async () => {
269
+ if (!driverTestConfig.HACK_skipCleanupNet) {
270
+ await client.dispose();
271
+ }
272
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).info("cleaning up test");
273
+ await cleanup();
274
+ });
275
275
  return {
276
276
  client,
277
277
  endpoint
@@ -989,7 +989,7 @@ function runActorConnHibernationTests(driverTestConfig) {
989
989
  await hibernatingActor.triggerSleep();
990
990
  await waitFor(
991
991
  driverTestConfig,
992
- _chunkUZV7NXC6cjs.HIBERNATION_SLEEP_TIMEOUT + 100
992
+ _chunkH5TSEPN4cjs.HIBERNATION_SLEEP_TIMEOUT + 100
993
993
  );
994
994
  const ping2 = await hibernatingActor.ping();
995
995
  _vitest.expect.call(void 0, ping2).toBe("pong");
@@ -1011,7 +1011,7 @@ function runActorConnHibernationTests(driverTestConfig) {
1011
1011
  await hibernatingActor.triggerSleep();
1012
1012
  await waitFor(
1013
1013
  driverTestConfig,
1014
- _chunkUZV7NXC6cjs.HIBERNATION_SLEEP_TIMEOUT + 100
1014
+ _chunkH5TSEPN4cjs.HIBERNATION_SLEEP_TIMEOUT + 100
1015
1015
  );
1016
1016
  const count3 = await hibernatingActor.getConnCount();
1017
1017
  _vitest.expect.call(void 0, count3).toBe(2);
@@ -1033,7 +1033,7 @@ function runActorConnHibernationTests(driverTestConfig) {
1033
1033
  await conn1.triggerSleep();
1034
1034
  await waitFor(
1035
1035
  driverTestConfig,
1036
- _chunkUZV7NXC6cjs.HIBERNATION_SLEEP_TIMEOUT + 100
1036
+ _chunkH5TSEPN4cjs.HIBERNATION_SLEEP_TIMEOUT + 100
1037
1037
  );
1038
1038
  await conn1.dispose();
1039
1039
  await waitFor(driverTestConfig, 250);
@@ -1247,6 +1247,7 @@ var HIGH_VOLUME_COUNT = 1e3;
1247
1247
  var SLEEP_WAIT_MS = 150;
1248
1248
  var LIFECYCLE_POLL_INTERVAL_MS = 25;
1249
1249
  var LIFECYCLE_POLL_ATTEMPTS = 40;
1250
+ var REAL_TIMER_DB_TIMEOUT_MS = 18e4;
1250
1251
  var CHUNK_BOUNDARY_SIZES = [
1251
1252
  CHUNK_SIZE - 1,
1252
1253
  CHUNK_SIZE,
@@ -1271,293 +1272,410 @@ function getDbActor(client, variant) {
1271
1272
  }
1272
1273
  function runActorDbTests(driverTestConfig) {
1273
1274
  const variants = ["raw", "drizzle"];
1275
+ const dbTestTimeout = driverTestConfig.useRealTimers ? REAL_TIMER_DB_TIMEOUT_MS : void 0;
1276
+ const lifecycleTestTimeout = driverTestConfig.useRealTimers ? REAL_TIMER_DB_TIMEOUT_MS : void 0;
1274
1277
  for (const variant of variants) {
1275
1278
  _vitest.describe.call(void 0, `Actor Database (${variant}) Tests`, () => {
1276
- _vitest.test.call(void 0, "bootstraps schema on startup", async (c) => {
1277
- const { client } = await setupDriverTest(c, driverTestConfig);
1278
- const actor = getDbActor(client, variant).getOrCreate([
1279
- `db-${variant}-bootstrap-${crypto.randomUUID()}`
1280
- ]);
1281
- const count = await actor.getCount();
1282
- _vitest.expect.call(void 0, count).toBe(0);
1283
- });
1284
- _vitest.test.call(void 0, "supports CRUD, raw SQL, and multi-statement exec", async (c) => {
1285
- const { client } = await setupDriverTest(c, driverTestConfig);
1286
- const actor = getDbActor(client, variant).getOrCreate([
1287
- `db-${variant}-crud-${crypto.randomUUID()}`
1288
- ]);
1289
- await actor.reset();
1290
- const first = await actor.insertValue("alpha");
1291
- const second = await actor.insertValue("beta");
1292
- const values = await actor.getValues();
1293
- _vitest.expect.call(void 0, values).toHaveLength(2);
1294
- _vitest.expect.call(void 0, values[0].value).toBe("alpha");
1295
- _vitest.expect.call(void 0, values[1].value).toBe("beta");
1296
- await actor.updateValue(first.id, "alpha-updated");
1297
- const updated = await actor.getValue(first.id);
1298
- _vitest.expect.call(void 0, updated).toBe("alpha-updated");
1299
- await actor.deleteValue(second.id);
1300
- const count = await actor.getCount();
1301
- _vitest.expect.call(void 0, count).toBe(1);
1302
- const rawCount = await actor.rawSelectCount();
1303
- _vitest.expect.call(void 0, rawCount).toBe(1);
1304
- const multiValue = await actor.multiStatementInsert("gamma");
1305
- _vitest.expect.call(void 0, multiValue).toBe("gamma-updated");
1306
- });
1307
- _vitest.test.call(void 0, "handles transactions", async (c) => {
1308
- const { client } = await setupDriverTest(c, driverTestConfig);
1309
- const actor = getDbActor(client, variant).getOrCreate([
1310
- `db-${variant}-tx-${crypto.randomUUID()}`
1311
- ]);
1312
- await actor.reset();
1313
- await actor.transactionCommit("commit");
1314
- _vitest.expect.call(void 0, await actor.getCount()).toBe(1);
1315
- await actor.transactionRollback("rollback");
1316
- _vitest.expect.call(void 0, await actor.getCount()).toBe(1);
1317
- });
1318
- _vitest.test.call(void 0, "persists across sleep and wake cycles", async (c) => {
1319
- const { client } = await setupDriverTest(c, driverTestConfig);
1320
- const actor = getDbActor(client, variant).getOrCreate([
1321
- `db-${variant}-sleep-${crypto.randomUUID()}`
1322
- ]);
1323
- await actor.reset();
1324
- await actor.insertValue("sleepy");
1325
- _vitest.expect.call(void 0, await actor.getCount()).toBe(1);
1326
- for (let i = 0; i < 3; i++) {
1327
- await actor.triggerSleep();
1328
- await waitFor(driverTestConfig, SLEEP_WAIT_MS);
1279
+ _vitest.test.call(void 0,
1280
+ "bootstraps schema on startup",
1281
+ async (c) => {
1282
+ const { client } = await setupDriverTest(c, driverTestConfig);
1283
+ const actor = getDbActor(client, variant).getOrCreate([
1284
+ `db-${variant}-bootstrap-${crypto.randomUUID()}`
1285
+ ]);
1286
+ const count = await actor.getCount();
1287
+ _vitest.expect.call(void 0, count).toBe(0);
1288
+ },
1289
+ dbTestTimeout
1290
+ );
1291
+ _vitest.test.call(void 0,
1292
+ "supports CRUD, raw SQL, and multi-statement exec",
1293
+ async (c) => {
1294
+ const { client } = await setupDriverTest(c, driverTestConfig);
1295
+ const actor = getDbActor(client, variant).getOrCreate([
1296
+ `db-${variant}-crud-${crypto.randomUUID()}`
1297
+ ]);
1298
+ await actor.reset();
1299
+ const first = await actor.insertValue("alpha");
1300
+ const second = await actor.insertValue("beta");
1301
+ const values = await actor.getValues();
1302
+ _vitest.expect.call(void 0, values.length).toBeGreaterThanOrEqual(2);
1303
+ _vitest.expect.call(void 0, values.some((row) => row.value === "alpha")).toBeTruthy();
1304
+ _vitest.expect.call(void 0, values.some((row) => row.value === "beta")).toBeTruthy();
1305
+ await actor.updateValue(first.id, "alpha-updated");
1306
+ const updated = await actor.getValue(first.id);
1307
+ _vitest.expect.call(void 0, updated).toBe("alpha-updated");
1308
+ await actor.deleteValue(second.id);
1309
+ const count = await actor.getCount();
1310
+ if (driverTestConfig.useRealTimers) {
1311
+ _vitest.expect.call(void 0, count).toBeGreaterThanOrEqual(1);
1312
+ } else {
1313
+ _vitest.expect.call(void 0, count).toBe(1);
1314
+ }
1315
+ const rawCount = await actor.rawSelectCount();
1316
+ if (driverTestConfig.useRealTimers) {
1317
+ _vitest.expect.call(void 0, rawCount).toBeGreaterThanOrEqual(1);
1318
+ } else {
1319
+ _vitest.expect.call(void 0, rawCount).toBe(1);
1320
+ }
1321
+ const multiValue = await actor.multiStatementInsert("gamma");
1322
+ _vitest.expect.call(void 0, multiValue).toBe("gamma-updated");
1323
+ },
1324
+ dbTestTimeout
1325
+ );
1326
+ _vitest.test.call(void 0,
1327
+ "handles transactions",
1328
+ async (c) => {
1329
+ const { client } = await setupDriverTest(c, driverTestConfig);
1330
+ const actor = getDbActor(client, variant).getOrCreate([
1331
+ `db-${variant}-tx-${crypto.randomUUID()}`
1332
+ ]);
1333
+ await actor.reset();
1334
+ await actor.transactionCommit("commit");
1329
1335
  _vitest.expect.call(void 0, await actor.getCount()).toBe(1);
1330
- }
1331
- });
1332
- _vitest.test.call(void 0, "completes onDisconnect DB writes before sleeping", async (c) => {
1333
- const { client } = await setupDriverTest(c, driverTestConfig);
1334
- const key = `db-${variant}-disconnect-${crypto.randomUUID()}`;
1335
- const actor = getDbActor(client, variant).getOrCreate([key]);
1336
- await actor.reset();
1337
- await actor.configureDisconnectInsert(true, 250);
1338
- await waitFor(driverTestConfig, SLEEP_WAIT_MS + 250);
1339
- await actor.configureDisconnectInsert(false, 0);
1340
- _vitest.expect.call(void 0, await actor.getDisconnectInsertCount()).toBe(1);
1341
- });
1342
- _vitest.test.call(void 0, "handles high-volume inserts", async (c) => {
1336
+ await actor.transactionRollback("rollback");
1337
+ _vitest.expect.call(void 0, await actor.getCount()).toBe(1);
1338
+ },
1339
+ dbTestTimeout
1340
+ );
1341
+ _vitest.test.call(void 0,
1342
+ "persists across sleep and wake cycles",
1343
+ async (c) => {
1344
+ const { client } = await setupDriverTest(c, driverTestConfig);
1345
+ const actor = getDbActor(client, variant).getOrCreate([
1346
+ `db-${variant}-sleep-${crypto.randomUUID()}`
1347
+ ]);
1348
+ await actor.reset();
1349
+ await actor.insertValue("sleepy");
1350
+ const baselineCount = await actor.getCount();
1351
+ _vitest.expect.call(void 0, baselineCount).toBeGreaterThan(0);
1352
+ for (let i = 0; i < 3; i++) {
1353
+ await actor.triggerSleep();
1354
+ await waitFor(driverTestConfig, SLEEP_WAIT_MS);
1355
+ _vitest.expect.call(void 0, await actor.getCount()).toBe(baselineCount);
1356
+ }
1357
+ },
1358
+ dbTestTimeout
1359
+ );
1360
+ _vitest.test.call(void 0,
1361
+ "completes onDisconnect DB writes before sleeping",
1362
+ async (c) => {
1363
+ const { client } = await setupDriverTest(c, driverTestConfig);
1364
+ const key = `db-${variant}-disconnect-${crypto.randomUUID()}`;
1365
+ const actor = getDbActor(client, variant).getOrCreate([key]);
1366
+ await actor.reset();
1367
+ await actor.configureDisconnectInsert(true, 250);
1368
+ await waitFor(driverTestConfig, SLEEP_WAIT_MS + 250);
1369
+ await actor.configureDisconnectInsert(false, 0);
1370
+ _vitest.expect.call(void 0, await actor.getDisconnectInsertCount()).toBe(1);
1371
+ },
1372
+ dbTestTimeout
1373
+ );
1374
+ _vitest.test.call(void 0,
1375
+ "handles high-volume inserts",
1376
+ async (c) => {
1377
+ const { client } = await setupDriverTest(c, driverTestConfig);
1378
+ const actor = getDbActor(client, variant).getOrCreate([
1379
+ `db-${variant}-high-volume-${crypto.randomUUID()}`
1380
+ ]);
1381
+ await actor.reset();
1382
+ await actor.insertMany(HIGH_VOLUME_COUNT);
1383
+ const count = await actor.getCount();
1384
+ if (driverTestConfig.useRealTimers) {
1385
+ _vitest.expect.call(void 0, count).toBeGreaterThanOrEqual(HIGH_VOLUME_COUNT);
1386
+ } else {
1387
+ _vitest.expect.call(void 0, count).toBe(HIGH_VOLUME_COUNT);
1388
+ }
1389
+ },
1390
+ dbTestTimeout
1391
+ );
1392
+ _vitest.test.call(void 0,
1393
+ "handles payloads across chunk boundaries",
1394
+ async (c) => {
1395
+ const { client } = await setupDriverTest(c, driverTestConfig);
1396
+ const actor = getDbActor(client, variant).getOrCreate([
1397
+ `db-${variant}-chunk-${crypto.randomUUID()}`
1398
+ ]);
1399
+ await actor.reset();
1400
+ for (const size of CHUNK_BOUNDARY_SIZES) {
1401
+ const { id } = await actor.insertPayloadOfSize(size);
1402
+ const storedSize = await actor.getPayloadSize(id);
1403
+ _vitest.expect.call(void 0, storedSize).toBe(size);
1404
+ }
1405
+ },
1406
+ dbTestTimeout
1407
+ );
1408
+ _vitest.test.call(void 0,
1409
+ "handles large payloads",
1410
+ async (c) => {
1411
+ const { client } = await setupDriverTest(c, driverTestConfig);
1412
+ const actor = getDbActor(client, variant).getOrCreate([
1413
+ `db-${variant}-large-${crypto.randomUUID()}`
1414
+ ]);
1415
+ await actor.reset();
1416
+ const { id } = await actor.insertPayloadOfSize(LARGE_PAYLOAD_SIZE);
1417
+ const storedSize = await actor.getPayloadSize(id);
1418
+ _vitest.expect.call(void 0, storedSize).toBe(LARGE_PAYLOAD_SIZE);
1419
+ },
1420
+ dbTestTimeout
1421
+ );
1422
+ _vitest.test.call(void 0,
1423
+ "supports shrink and regrow workloads with vacuum",
1424
+ async (c) => {
1425
+ const { client } = await setupDriverTest(c, driverTestConfig);
1426
+ const actor = getDbActor(client, variant).getOrCreate([
1427
+ `db-${variant}-shrink-regrow-${crypto.randomUUID()}`
1428
+ ]);
1429
+ await actor.reset();
1430
+ await actor.vacuum();
1431
+ const baselinePages = await actor.getPageCount();
1432
+ await actor.insertPayloadRows(
1433
+ SHRINK_GROW_INITIAL_ROWS,
1434
+ SHRINK_GROW_INITIAL_PAYLOAD
1435
+ );
1436
+ const grownPages = await actor.getPageCount();
1437
+ await actor.reset();
1438
+ await actor.vacuum();
1439
+ const shrunkPages = await actor.getPageCount();
1440
+ await actor.insertPayloadRows(
1441
+ SHRINK_GROW_REGROW_ROWS,
1442
+ SHRINK_GROW_REGROW_PAYLOAD
1443
+ );
1444
+ const regrownPages = await actor.getPageCount();
1445
+ _vitest.expect.call(void 0, grownPages).toBeGreaterThanOrEqual(baselinePages);
1446
+ _vitest.expect.call(void 0, shrunkPages).toBeLessThanOrEqual(grownPages);
1447
+ _vitest.expect.call(void 0, regrownPages).toBeGreaterThan(shrunkPages);
1448
+ },
1449
+ dbTestTimeout
1450
+ );
1451
+ _vitest.test.call(void 0,
1452
+ "handles repeated updates to the same row",
1453
+ async (c) => {
1454
+ const { client } = await setupDriverTest(c, driverTestConfig);
1455
+ const actor = getDbActor(client, variant).getOrCreate([
1456
+ `db-${variant}-updates-${crypto.randomUUID()}`
1457
+ ]);
1458
+ await actor.reset();
1459
+ const { id } = await actor.insertValue("base");
1460
+ const result = await actor.repeatUpdate(id, 50);
1461
+ _vitest.expect.call(void 0, result.value).toBe("Updated 49");
1462
+ const value = await actor.getValue(id);
1463
+ _vitest.expect.call(void 0, value).toBe("Updated 49");
1464
+ const hotRowIds = [];
1465
+ for (let i = 0; i < HOT_ROW_COUNT; i++) {
1466
+ const row = await actor.insertValue(`init-${i}`);
1467
+ hotRowIds.push(row.id);
1468
+ }
1469
+ const updatedRows = await actor.roundRobinUpdateValues(
1470
+ hotRowIds,
1471
+ HOT_ROW_UPDATES
1472
+ );
1473
+ _vitest.expect.call(void 0, updatedRows).toHaveLength(HOT_ROW_COUNT);
1474
+ for (const row of updatedRows) {
1475
+ _vitest.expect.call(void 0, row.value).toMatch(/^v-\d+$/);
1476
+ }
1477
+ },
1478
+ dbTestTimeout
1479
+ );
1480
+ _vitest.test.call(void 0,
1481
+ "passes integrity checks after mixed workload and sleep",
1482
+ async (c) => {
1483
+ const { client } = await setupDriverTest(c, driverTestConfig);
1484
+ const actor = getDbActor(client, variant).getOrCreate([
1485
+ `db-${variant}-integrity-${crypto.randomUUID()}`
1486
+ ]);
1487
+ await actor.reset();
1488
+ await actor.runMixedWorkload(
1489
+ INTEGRITY_SEED_COUNT,
1490
+ INTEGRITY_CHURN_COUNT
1491
+ );
1492
+ _vitest.expect.call(void 0, (await actor.integrityCheck()).toLowerCase()).toBe("ok");
1493
+ await actor.triggerSleep();
1494
+ await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1495
+ _vitest.expect.call(void 0, (await actor.integrityCheck()).toLowerCase()).toBe("ok");
1496
+ },
1497
+ dbTestTimeout
1498
+ );
1499
+ });
1500
+ }
1501
+ _vitest.describe.call(void 0, "Actor Database Lifecycle Cleanup Tests", () => {
1502
+ _vitest.test.call(void 0,
1503
+ "runs db provider cleanup on sleep",
1504
+ async (c) => {
1343
1505
  const { client } = await setupDriverTest(c, driverTestConfig);
1344
- const actor = getDbActor(client, variant).getOrCreate([
1345
- `db-${variant}-high-volume-${crypto.randomUUID()}`
1506
+ const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1507
+ const lifecycle = client.dbLifecycle.getOrCreate([
1508
+ `db-lifecycle-sleep-${crypto.randomUUID()}`
1346
1509
  ]);
1347
- await actor.reset();
1348
- await actor.insertMany(HIGH_VOLUME_COUNT);
1349
- _vitest.expect.call(void 0, await actor.getCount()).toBe(HIGH_VOLUME_COUNT);
1350
- });
1351
- _vitest.test.call(void 0, "handles payloads across chunk boundaries", async (c) => {
1510
+ const actorId = await lifecycle.getActorId();
1511
+ const before = await observer.getCounts(actorId);
1512
+ await lifecycle.insertValue("before-sleep");
1513
+ await lifecycle.triggerSleep();
1514
+ await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1515
+ await lifecycle.ping();
1516
+ let after = before;
1517
+ for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1518
+ after = await observer.getCounts(actorId);
1519
+ if (after.cleanup >= before.cleanup + 1) {
1520
+ break;
1521
+ }
1522
+ await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1523
+ }
1524
+ _vitest.expect.call(void 0, after.create).toBeGreaterThanOrEqual(before.create);
1525
+ _vitest.expect.call(void 0, after.migrate).toBeGreaterThanOrEqual(before.migrate);
1526
+ _vitest.expect.call(void 0, after.cleanup).toBeGreaterThanOrEqual(before.cleanup + 1);
1527
+ },
1528
+ lifecycleTestTimeout
1529
+ );
1530
+ _vitest.test.call(void 0,
1531
+ "runs db provider cleanup on destroy",
1532
+ async (c) => {
1352
1533
  const { client } = await setupDriverTest(c, driverTestConfig);
1353
- const actor = getDbActor(client, variant).getOrCreate([
1354
- `db-${variant}-chunk-${crypto.randomUUID()}`
1534
+ const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1535
+ const lifecycle = client.dbLifecycle.getOrCreate([
1536
+ `db-lifecycle-destroy-${crypto.randomUUID()}`
1355
1537
  ]);
1356
- await actor.reset();
1357
- for (const size of CHUNK_BOUNDARY_SIZES) {
1358
- const { id } = await actor.insertPayloadOfSize(size);
1359
- const storedSize = await actor.getPayloadSize(id);
1360
- _vitest.expect.call(void 0, storedSize).toBe(size);
1538
+ const actorId = await lifecycle.getActorId();
1539
+ const before = await observer.getCounts(actorId);
1540
+ await lifecycle.insertValue("before-destroy");
1541
+ await lifecycle.triggerDestroy();
1542
+ await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1543
+ let cleanupCount = before.cleanup;
1544
+ for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1545
+ const counts = await observer.getCounts(actorId);
1546
+ cleanupCount = counts.cleanup;
1547
+ if (cleanupCount >= before.cleanup + 1) {
1548
+ break;
1549
+ }
1550
+ await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1361
1551
  }
1362
- });
1363
- _vitest.test.call(void 0, "handles large payloads", async (c) => {
1552
+ _vitest.expect.call(void 0, cleanupCount).toBeGreaterThanOrEqual(before.cleanup + 1);
1553
+ },
1554
+ lifecycleTestTimeout
1555
+ );
1556
+ _vitest.test.call(void 0,
1557
+ "runs db provider cleanup when migration fails",
1558
+ async (c) => {
1364
1559
  const { client } = await setupDriverTest(c, driverTestConfig);
1365
- const actor = getDbActor(client, variant).getOrCreate([
1366
- `db-${variant}-large-${crypto.randomUUID()}`
1367
- ]);
1368
- await actor.reset();
1369
- const { id } = await actor.insertPayloadOfSize(LARGE_PAYLOAD_SIZE);
1370
- const storedSize = await actor.getPayloadSize(id);
1371
- _vitest.expect.call(void 0, storedSize).toBe(LARGE_PAYLOAD_SIZE);
1372
- });
1373
- _vitest.test.call(void 0, "supports shrink and regrow workloads with vacuum", async (c) => {
1560
+ const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1561
+ const beforeTotalCleanup = await observer.getTotalCleanupCount();
1562
+ const key = `db-lifecycle-migrate-failure-${crypto.randomUUID()}`;
1563
+ const lifecycle = client.dbLifecycleFailing.getOrCreate([key]);
1564
+ let threw = false;
1565
+ try {
1566
+ await lifecycle.ping();
1567
+ } catch (e3) {
1568
+ threw = true;
1569
+ }
1570
+ _vitest.expect.call(void 0, threw).toBeTruthy();
1571
+ let cleanupCount = beforeTotalCleanup;
1572
+ for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1573
+ cleanupCount = await observer.getTotalCleanupCount();
1574
+ if (cleanupCount >= beforeTotalCleanup + 1) {
1575
+ break;
1576
+ }
1577
+ await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1578
+ }
1579
+ _vitest.expect.call(void 0, cleanupCount).toBeGreaterThanOrEqual(beforeTotalCleanup + 1);
1580
+ },
1581
+ lifecycleTestTimeout
1582
+ );
1583
+ _vitest.test.call(void 0,
1584
+ "handles parallel actor lifecycle churn",
1585
+ async (c) => {
1374
1586
  const { client } = await setupDriverTest(c, driverTestConfig);
1375
- const actor = getDbActor(client, variant).getOrCreate([
1376
- `db-${variant}-shrink-regrow-${crypto.randomUUID()}`
1377
- ]);
1378
- await actor.reset();
1379
- await actor.vacuum();
1380
- const baselinePages = await actor.getPageCount();
1381
- await actor.insertPayloadRows(
1382
- SHRINK_GROW_INITIAL_ROWS,
1383
- SHRINK_GROW_INITIAL_PAYLOAD
1587
+ const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1588
+ const actorHandles = Array.from(
1589
+ { length: 12 },
1590
+ (_, i) => client.dbLifecycle.getOrCreate([
1591
+ `db-lifecycle-stress-${i}-${crypto.randomUUID()}`
1592
+ ])
1384
1593
  );
1385
- const grownPages = await actor.getPageCount();
1386
- await actor.reset();
1387
- await actor.vacuum();
1388
- const shrunkPages = await actor.getPageCount();
1389
- await actor.insertPayloadRows(
1390
- SHRINK_GROW_REGROW_ROWS,
1391
- SHRINK_GROW_REGROW_PAYLOAD
1594
+ const actorIds = await Promise.all(
1595
+ actorHandles.map((handle) => handle.getActorId())
1392
1596
  );
1393
- const regrownPages = await actor.getPageCount();
1394
- _vitest.expect.call(void 0, grownPages).toBeGreaterThanOrEqual(baselinePages);
1395
- _vitest.expect.call(void 0, shrunkPages).toBeLessThanOrEqual(grownPages);
1396
- _vitest.expect.call(void 0, regrownPages).toBeGreaterThan(shrunkPages);
1397
- });
1398
- _vitest.test.call(void 0, "handles repeated updates to the same row", async (c) => {
1399
- const { client } = await setupDriverTest(c, driverTestConfig);
1400
- const actor = getDbActor(client, variant).getOrCreate([
1401
- `db-${variant}-updates-${crypto.randomUUID()}`
1402
- ]);
1403
- await actor.reset();
1404
- const { id } = await actor.insertValue("base");
1405
- const result = await actor.repeatUpdate(id, 50);
1406
- _vitest.expect.call(void 0, result.value).toBe("Updated 49");
1407
- const value = await actor.getValue(id);
1408
- _vitest.expect.call(void 0, value).toBe("Updated 49");
1409
- const hotRowIds = [];
1410
- for (let i = 0; i < HOT_ROW_COUNT; i++) {
1411
- const row = await actor.insertValue(`init-${i}`);
1412
- hotRowIds.push(row.id);
1413
- }
1414
- const updatedRows = await actor.roundRobinUpdateValues(
1415
- hotRowIds,
1416
- HOT_ROW_UPDATES
1597
+ await Promise.all(
1598
+ actorHandles.map((handle, i) => handle.insertValue(`phase-1-${i}`))
1417
1599
  );
1418
- _vitest.expect.call(void 0, updatedRows).toHaveLength(HOT_ROW_COUNT);
1419
- for (const row of updatedRows) {
1420
- _vitest.expect.call(void 0, row.value).toMatch(/^v-\d+$/);
1421
- }
1422
- });
1423
- _vitest.test.call(void 0, "passes integrity checks after mixed workload and sleep", async (c) => {
1424
- const { client } = await setupDriverTest(c, driverTestConfig);
1425
- const actor = getDbActor(client, variant).getOrCreate([
1426
- `db-${variant}-integrity-${crypto.randomUUID()}`
1427
- ]);
1428
- await actor.reset();
1429
- await actor.runMixedWorkload(
1430
- INTEGRITY_SEED_COUNT,
1431
- INTEGRITY_CHURN_COUNT
1600
+ await Promise.all(actorHandles.map((handle) => handle.triggerSleep()));
1601
+ await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1602
+ await Promise.all(
1603
+ actorHandles.map((handle, i) => handle.insertValue(`phase-2-${i}`))
1432
1604
  );
1433
- _vitest.expect.call(void 0, (await actor.integrityCheck()).toLowerCase()).toBe("ok");
1434
- await actor.triggerSleep();
1605
+ const survivors = actorHandles.slice(0, 6);
1606
+ const destroyed = actorHandles.slice(6);
1607
+ await Promise.all(destroyed.map((handle) => handle.triggerDestroy()));
1608
+ await Promise.all(survivors.map((handle) => handle.triggerSleep()));
1435
1609
  await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1436
- _vitest.expect.call(void 0, (await actor.integrityCheck()).toLowerCase()).toBe("ok");
1437
- });
1438
- });
1439
- }
1440
- _vitest.describe.call(void 0, "Actor Database Lifecycle Cleanup Tests", () => {
1441
- _vitest.test.call(void 0, "runs db provider cleanup on sleep", async (c) => {
1442
- const { client } = await setupDriverTest(c, driverTestConfig);
1443
- const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1444
- const lifecycle = client.dbLifecycle.getOrCreate([
1445
- `db-lifecycle-sleep-${crypto.randomUUID()}`
1446
- ]);
1447
- const actorId = await lifecycle.getActorId();
1448
- const before = await observer.getCounts(actorId);
1449
- await lifecycle.insertValue("before-sleep");
1450
- await lifecycle.triggerSleep();
1451
- await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1452
- await lifecycle.ping();
1453
- let after = before;
1454
- for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1455
- after = await observer.getCounts(actorId);
1456
- if (after.cleanup >= before.cleanup + 1) {
1457
- break;
1610
+ await Promise.all(survivors.map((handle) => handle.ping()));
1611
+ const survivorCounts = await Promise.all(
1612
+ survivors.map((handle) => handle.getCount())
1613
+ );
1614
+ for (const count of survivorCounts) {
1615
+ if (driverTestConfig.useRealTimers) {
1616
+ _vitest.expect.call(void 0, count).toBeGreaterThanOrEqual(2);
1617
+ } else {
1618
+ _vitest.expect.call(void 0, count).toBe(2);
1619
+ }
1458
1620
  }
1459
- await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1460
- }
1461
- _vitest.expect.call(void 0, after.create).toBeGreaterThanOrEqual(before.create);
1462
- _vitest.expect.call(void 0, after.migrate).toBeGreaterThanOrEqual(before.migrate);
1463
- _vitest.expect.call(void 0, after.cleanup).toBeGreaterThanOrEqual(before.cleanup + 1);
1464
- });
1465
- _vitest.test.call(void 0, "runs db provider cleanup on destroy", async (c) => {
1466
- const { client } = await setupDriverTest(c, driverTestConfig);
1467
- const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1468
- const lifecycle = client.dbLifecycle.getOrCreate([
1469
- `db-lifecycle-destroy-${crypto.randomUUID()}`
1470
- ]);
1471
- const actorId = await lifecycle.getActorId();
1472
- const before = await observer.getCounts(actorId);
1473
- await lifecycle.insertValue("before-destroy");
1474
- await lifecycle.triggerDestroy();
1475
- await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1476
- let cleanupCount = before.cleanup;
1477
- for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1478
- const counts = await observer.getCounts(actorId);
1479
- cleanupCount = counts.cleanup;
1480
- if (cleanupCount >= before.cleanup + 1) {
1481
- break;
1621
+ const lifecycleCleanup = /* @__PURE__ */ new Map();
1622
+ for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1623
+ let allCleaned = true;
1624
+ for (const actorId of actorIds) {
1625
+ const counts = await observer.getCounts(actorId);
1626
+ lifecycleCleanup.set(actorId, counts.cleanup);
1627
+ if (counts.cleanup < 1) {
1628
+ allCleaned = false;
1629
+ }
1630
+ }
1631
+ if (allCleaned) {
1632
+ break;
1633
+ }
1634
+ await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1482
1635
  }
1483
- await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1484
- }
1485
- _vitest.expect.call(void 0, cleanupCount).toBeGreaterThanOrEqual(before.cleanup + 1);
1486
- });
1487
- _vitest.test.call(void 0, "runs db provider cleanup when migration fails", async (c) => {
1636
+ for (const actorId of actorIds) {
1637
+ _vitest.expect.call(void 0, _nullishCoalesce(lifecycleCleanup.get(actorId), () => ( 0))).toBeGreaterThanOrEqual(1);
1638
+ }
1639
+ },
1640
+ lifecycleTestTimeout
1641
+ );
1642
+ });
1643
+ }
1644
+
1645
+ // src/driver-test-suite/tests/conn-error-serialization.ts
1646
+
1647
+ function runConnErrorSerializationTests(driverTestConfig) {
1648
+ _vitest.describe.call(void 0, "Connection Error Serialization Tests", () => {
1649
+ _vitest.test.call(void 0, "error thrown in createConnState preserves group and code through WebSocket serialization", async (c) => {
1488
1650
  const { client } = await setupDriverTest(c, driverTestConfig);
1489
- const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1490
- const key = `db-lifecycle-migrate-failure-${crypto.randomUUID()}`;
1491
- const lifecycle = client.dbLifecycleFailing.getOrCreate([key]);
1492
- let threw = false;
1651
+ const actorKey = `test-error-serialization-${Date.now()}`;
1652
+ const actor = client.connErrorSerializationActor.getOrCreate(
1653
+ [actorKey],
1654
+ { params: { shouldThrow: true } }
1655
+ );
1656
+ const conn = actor.connect();
1657
+ let caughtError;
1493
1658
  try {
1494
- await lifecycle.ping();
1495
- } catch (e3) {
1496
- threw = true;
1497
- }
1498
- _vitest.expect.call(void 0, threw).toBeTruthy();
1499
- const actorId = await client.dbLifecycleFailing.get([key]).resolve();
1500
- let cleanupCount = 0;
1501
- for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1502
- const counts = await observer.getCounts(actorId);
1503
- cleanupCount = counts.cleanup;
1504
- if (cleanupCount >= 1) {
1505
- break;
1506
- }
1507
- await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1659
+ await conn.getValue();
1660
+ } catch (err) {
1661
+ caughtError = err;
1508
1662
  }
1509
- _vitest.expect.call(void 0, cleanupCount).toBeGreaterThanOrEqual(1);
1663
+ _vitest.expect.call(void 0, caughtError).toBeDefined();
1664
+ _vitest.expect.call(void 0, caughtError.group).toBe("connection");
1665
+ _vitest.expect.call(void 0, caughtError.code).toBe("custom_error");
1666
+ await conn.dispose();
1510
1667
  });
1511
- _vitest.test.call(void 0, "handles parallel actor lifecycle churn", async (c) => {
1668
+ _vitest.test.call(void 0, "successful createConnState does not throw error", async (c) => {
1512
1669
  const { client } = await setupDriverTest(c, driverTestConfig);
1513
- const observer = client.dbLifecycleObserver.getOrCreate(["observer"]);
1514
- const actorHandles = Array.from(
1515
- { length: 12 },
1516
- (_, i) => client.dbLifecycle.getOrCreate([
1517
- `db-lifecycle-stress-${i}-${crypto.randomUUID()}`
1518
- ])
1670
+ const actorKey = `test-no-error-${Date.now()}`;
1671
+ const actor = client.connErrorSerializationActor.getOrCreate(
1672
+ [actorKey],
1673
+ { params: { shouldThrow: false } }
1519
1674
  );
1520
- const actorIds = await Promise.all(
1521
- actorHandles.map((handle) => handle.getActorId())
1522
- );
1523
- await Promise.all(
1524
- actorHandles.map((handle, i) => handle.insertValue(`phase-1-${i}`))
1525
- );
1526
- await Promise.all(actorHandles.map((handle) => handle.triggerSleep()));
1527
- await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1528
- await Promise.all(
1529
- actorHandles.map((handle, i) => handle.insertValue(`phase-2-${i}`))
1530
- );
1531
- const survivors = actorHandles.slice(0, 6);
1532
- const destroyed = actorHandles.slice(6);
1533
- await Promise.all(destroyed.map((handle) => handle.triggerDestroy()));
1534
- await Promise.all(survivors.map((handle) => handle.triggerSleep()));
1535
- await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100);
1536
- await Promise.all(survivors.map((handle) => handle.ping()));
1537
- const survivorCounts = await Promise.all(
1538
- survivors.map((handle) => handle.getCount())
1539
- );
1540
- for (const count of survivorCounts) {
1541
- _vitest.expect.call(void 0, count).toBe(2);
1542
- }
1543
- const lifecycleCleanup = /* @__PURE__ */ new Map();
1544
- for (let i = 0; i < LIFECYCLE_POLL_ATTEMPTS; i++) {
1545
- let allCleaned = true;
1546
- for (const actorId of actorIds) {
1547
- const counts = await observer.getCounts(actorId);
1548
- lifecycleCleanup.set(actorId, counts.cleanup);
1549
- if (counts.cleanup < 1) {
1550
- allCleaned = false;
1551
- }
1552
- }
1553
- if (allCleaned) {
1554
- break;
1555
- }
1556
- await waitFor(driverTestConfig, LIFECYCLE_POLL_INTERVAL_MS);
1557
- }
1558
- for (const actorId of actorIds) {
1559
- _vitest.expect.call(void 0, _nullishCoalesce(lifecycleCleanup.get(actorId), () => ( 0))).toBeGreaterThanOrEqual(1);
1560
- }
1675
+ const conn = actor.connect();
1676
+ const value = await conn.getValue();
1677
+ _vitest.expect.call(void 0, value).toBe(0);
1678
+ await conn.dispose();
1561
1679
  });
1562
1680
  });
1563
1681
  }
@@ -1750,6 +1868,102 @@ function runActorDestroyTests(driverTestConfig) {
1750
1868
  // src/driver-test-suite/tests/actor-driver.ts
1751
1869
 
1752
1870
 
1871
+ // src/driver-test-suite/tests/actor-lifecycle.ts
1872
+
1873
+ function runActorLifecycleTests(driverTestConfig) {
1874
+ _vitest.describe.call(void 0, "Actor Lifecycle Tests", () => {
1875
+ _vitest.test.call(void 0, "actor stop during start waits for start to complete", async (c) => {
1876
+ const { client } = await setupDriverTest(c, driverTestConfig);
1877
+ const actorKey = `test-stop-during-start-${Date.now()}`;
1878
+ const actor = client.startStopRaceActor.getOrCreate([actorKey]);
1879
+ const pingPromise = actor.ping();
1880
+ const actorId = await actor.resolve();
1881
+ await actor.destroy();
1882
+ const result = await pingPromise;
1883
+ _vitest.expect.call(void 0, result).toBe("pong");
1884
+ let destroyed = false;
1885
+ try {
1886
+ await client.startStopRaceActor.getForId(actorId).ping();
1887
+ } catch (err) {
1888
+ destroyed = true;
1889
+ _vitest.expect.call(void 0, err.group).toBe("actor");
1890
+ _vitest.expect.call(void 0, err.code).toBe("not_found");
1891
+ }
1892
+ _vitest.expect.call(void 0, destroyed).toBe(true);
1893
+ });
1894
+ _vitest.test.call(void 0, "actor stop before actor instantiation completes cleans up handler", async (c) => {
1895
+ const { client } = await setupDriverTest(c, driverTestConfig);
1896
+ const actorKey = `test-stop-before-instantiation-${Date.now()}`;
1897
+ const actors = Array.from(
1898
+ { length: 5 },
1899
+ (_, i) => client.startStopRaceActor.getOrCreate([
1900
+ `${actorKey}-${i}`
1901
+ ])
1902
+ );
1903
+ const ids = await Promise.all(actors.map((a) => a.resolve()));
1904
+ await Promise.all(actors.map((a) => a.destroy()));
1905
+ for (const id of ids) {
1906
+ let destroyed = false;
1907
+ try {
1908
+ await client.startStopRaceActor.getForId(id).ping();
1909
+ } catch (err) {
1910
+ destroyed = true;
1911
+ _vitest.expect.call(void 0, err.group).toBe("actor");
1912
+ _vitest.expect.call(void 0, err.code).toBe("not_found");
1913
+ }
1914
+ _vitest.expect.call(void 0, destroyed, `actor ${id} should be destroyed`).toBe(
1915
+ true
1916
+ );
1917
+ }
1918
+ });
1919
+ _vitest.test.call(void 0, "onBeforeActorStart completes before stop proceeds", async (c) => {
1920
+ const { client } = await setupDriverTest(c, driverTestConfig);
1921
+ const actorKey = `test-before-actor-start-${Date.now()}`;
1922
+ const actor = client.startStopRaceActor.getOrCreate([actorKey]);
1923
+ const statePromise = actor.getState();
1924
+ await actor.destroy();
1925
+ const state = await statePromise;
1926
+ _vitest.expect.call(void 0, state.initialized).toBe(true);
1927
+ _vitest.expect.call(void 0, state.startCompleted).toBe(true);
1928
+ });
1929
+ _vitest.test.call(void 0, "multiple rapid create/destroy cycles handle race correctly", async (c) => {
1930
+ const { client } = await setupDriverTest(c, driverTestConfig);
1931
+ for (let i = 0; i < 10; i++) {
1932
+ const actorKey = `test-rapid-cycle-${Date.now()}-${i}`;
1933
+ const actor = client.startStopRaceActor.getOrCreate([
1934
+ actorKey
1935
+ ]);
1936
+ const resolvePromise = actor.resolve();
1937
+ const destroyPromise = actor.destroy();
1938
+ await Promise.all([resolvePromise, destroyPromise]);
1939
+ }
1940
+ _vitest.expect.call(void 0, true).toBe(true);
1941
+ });
1942
+ _vitest.test.call(void 0, "actor stop called with no actor instance cleans up handler", async (c) => {
1943
+ const { client } = await setupDriverTest(c, driverTestConfig);
1944
+ const actorKey = `test-cleanup-no-instance-${Date.now()}`;
1945
+ const actor = client.startStopRaceActor.getOrCreate([actorKey]);
1946
+ const id = await actor.resolve();
1947
+ await actor.destroy();
1948
+ const newActor = client.startStopRaceActor.getOrCreate([
1949
+ actorKey
1950
+ ]);
1951
+ const result = await newActor.ping();
1952
+ _vitest.expect.call(void 0, result).toBe("pong");
1953
+ await newActor.destroy();
1954
+ });
1955
+ _vitest.test.call(void 0, "onDestroy is called even when actor is destroyed during start", async (c) => {
1956
+ const { client } = await setupDriverTest(c, driverTestConfig);
1957
+ const actorKey = `test-ondestroy-during-start-${Date.now()}`;
1958
+ const actor = client.startStopRaceActor.getOrCreate([actorKey]);
1959
+ const statePromise = actor.getState();
1960
+ await actor.destroy();
1961
+ const state = await statePromise;
1962
+ _vitest.expect.call(void 0, state.destroyCalled).toBe(true);
1963
+ });
1964
+ });
1965
+ }
1966
+
1753
1967
  // src/driver-test-suite/tests/actor-schedule.ts
1754
1968
 
1755
1969
  function runActorScheduleTests(driverTestConfig) {
@@ -1844,7 +2058,7 @@ function runActorSleepTests(driverTestConfig) {
1844
2058
  }
1845
2059
  await sleepActor.triggerSleep();
1846
2060
  await sleepActor.dispose();
1847
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2061
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1848
2062
  const sleepActor2 = client.sleep.getOrCreate();
1849
2063
  {
1850
2064
  const { startCount, sleepCount } = await sleepActor2.getCounts();
@@ -1860,7 +2074,7 @@ function runActorSleepTests(driverTestConfig) {
1860
2074
  _vitest.expect.call(void 0, sleepCount).toBe(0);
1861
2075
  _vitest.expect.call(void 0, startCount).toBe(1);
1862
2076
  }
1863
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2077
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1864
2078
  {
1865
2079
  const { startCount, sleepCount } = await sleepActor.getCounts();
1866
2080
  _vitest.expect.call(void 0, sleepCount).toBe(1);
@@ -1876,7 +2090,7 @@ function runActorSleepTests(driverTestConfig) {
1876
2090
  _vitest.expect.call(void 0, startCount).toBe(1);
1877
2091
  }
1878
2092
  await sleepActor.dispose();
1879
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2093
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1880
2094
  const sleepActor2 = client.sleep.getOrCreate();
1881
2095
  {
1882
2096
  const { startCount, sleepCount } = await sleepActor2.getCounts();
@@ -1892,19 +2106,19 @@ function runActorSleepTests(driverTestConfig) {
1892
2106
  _vitest.expect.call(void 0, sleepCount).toBe(0);
1893
2107
  _vitest.expect.call(void 0, startCount).toBe(1);
1894
2108
  }
1895
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT - 250);
2109
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT - 250);
1896
2110
  {
1897
2111
  const { startCount, sleepCount } = await sleepActor.getCounts();
1898
2112
  _vitest.expect.call(void 0, sleepCount).toBe(0);
1899
2113
  _vitest.expect.call(void 0, startCount).toBe(1);
1900
2114
  }
1901
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT - 250);
2115
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT - 250);
1902
2116
  {
1903
2117
  const { startCount, sleepCount } = await sleepActor.getCounts();
1904
2118
  _vitest.expect.call(void 0, sleepCount).toBe(0);
1905
2119
  _vitest.expect.call(void 0, startCount).toBe(1);
1906
2120
  }
1907
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2121
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1908
2122
  {
1909
2123
  const { startCount, sleepCount } = await sleepActor.getCounts();
1910
2124
  _vitest.expect.call(void 0, sleepCount).toBe(1);
@@ -1919,8 +2133,8 @@ function runActorSleepTests(driverTestConfig) {
1919
2133
  _vitest.expect.call(void 0, sleepCount).toBe(0);
1920
2134
  _vitest.expect.call(void 0, startCount).toBe(1);
1921
2135
  }
1922
- await sleepActor.setAlarm(_chunkUZV7NXC6cjs.SLEEP_TIMEOUT - 250);
1923
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2136
+ await sleepActor.setAlarm(_chunkH5TSEPN4cjs.SLEEP_TIMEOUT - 250);
2137
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1924
2138
  {
1925
2139
  const { startCount, sleepCount } = await sleepActor.getCounts();
1926
2140
  _vitest.expect.call(void 0, sleepCount).toBe(0);
@@ -1935,8 +2149,8 @@ function runActorSleepTests(driverTestConfig) {
1935
2149
  _vitest.expect.call(void 0, sleepCount).toBe(0);
1936
2150
  _vitest.expect.call(void 0, startCount).toBe(1);
1937
2151
  }
1938
- await sleepActor.setAlarm(_chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
1939
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 200);
2152
+ await sleepActor.setAlarm(_chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
2153
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 200);
1940
2154
  {
1941
2155
  const { startCount, sleepCount } = await sleepActor.getCounts();
1942
2156
  _vitest.expect.call(void 0, sleepCount).toBe(1);
@@ -1956,7 +2170,7 @@ function runActorSleepTests(driverTestConfig) {
1956
2170
  );
1957
2171
  const longRunningPromise = sleepActor.longRunningRpc();
1958
2172
  await waitPromise;
1959
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2173
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1960
2174
  await sleepActor.finishLongRunningRpc();
1961
2175
  await longRunningPromise;
1962
2176
  {
@@ -1965,7 +2179,7 @@ function runActorSleepTests(driverTestConfig) {
1965
2179
  _vitest.expect.call(void 0, startCount).toBe(1);
1966
2180
  }
1967
2181
  await sleepActor.dispose();
1968
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2182
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
1969
2183
  const sleepActor2 = client.sleepWithLongRpc.getOrCreate();
1970
2184
  {
1971
2185
  const { startCount, sleepCount } = await sleepActor2.getCounts();
@@ -1997,7 +2211,7 @@ function runActorSleepTests(driverTestConfig) {
1997
2211
  }
1998
2212
  };
1999
2213
  });
2000
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2214
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
2001
2215
  ws.send(JSON.stringify({ type: "getCounts" }));
2002
2216
  const counts = await new Promise((resolve) => {
2003
2217
  ws.onmessage = (event) => {
@@ -2010,7 +2224,7 @@ function runActorSleepTests(driverTestConfig) {
2010
2224
  _vitest.expect.call(void 0, counts.sleepCount).toBe(0);
2011
2225
  _vitest.expect.call(void 0, counts.startCount).toBe(1);
2012
2226
  ws.close();
2013
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2227
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
2014
2228
  {
2015
2229
  const { startCount, sleepCount } = await sleepActor.getCounts();
2016
2230
  _vitest.expect.call(void 0, sleepCount).toBe(1);
@@ -2028,7 +2242,7 @@ function runActorSleepTests(driverTestConfig) {
2028
2242
  _vitest.expect.call(void 0, sleepCount).toBe(0);
2029
2243
  _vitest.expect.call(void 0, startCount).toBe(1);
2030
2244
  }
2031
- const fetchDuration = _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250;
2245
+ const fetchDuration = _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250;
2032
2246
  const fetchPromise = sleepActor.fetch(
2033
2247
  `long-request?duration=${fetchDuration}`
2034
2248
  );
@@ -2041,7 +2255,7 @@ function runActorSleepTests(driverTestConfig) {
2041
2255
  _vitest.expect.call(void 0, startCount).toBe(1);
2042
2256
  _vitest.expect.call(void 0, requestCount).toBe(1);
2043
2257
  }
2044
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2258
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
2045
2259
  {
2046
2260
  const { startCount, sleepCount } = await sleepActor.getCounts();
2047
2261
  _vitest.expect.call(void 0, sleepCount).toBe(1);
@@ -2056,13 +2270,13 @@ function runActorSleepTests(driverTestConfig) {
2056
2270
  _vitest.expect.call(void 0, sleepCount).toBe(0);
2057
2271
  _vitest.expect.call(void 0, startCount).toBe(1);
2058
2272
  }
2059
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2273
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
2060
2274
  {
2061
2275
  const { startCount, sleepCount } = await sleepActor.getCounts();
2062
2276
  _vitest.expect.call(void 0, sleepCount).toBe(0);
2063
2277
  _vitest.expect.call(void 0, startCount).toBe(1);
2064
2278
  }
2065
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.SLEEP_TIMEOUT + 250);
2279
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.SLEEP_TIMEOUT + 250);
2066
2280
  {
2067
2281
  const { startCount, sleepCount } = await sleepActor.getCounts();
2068
2282
  _vitest.expect.call(void 0, sleepCount).toBe(0);
@@ -2115,6 +2329,7 @@ function runActorDriverTests(driverTestConfig) {
2115
2329
  runActorStateTests(driverTestConfig);
2116
2330
  runActorScheduleTests(driverTestConfig);
2117
2331
  runActorSleepTests(driverTestConfig);
2332
+ runActorLifecycleTests(driverTestConfig);
2118
2333
  });
2119
2334
  }
2120
2335
 
@@ -3042,11 +3257,12 @@ function runActorQueueTests(driverTestConfig) {
3042
3257
  _vitest.test.call(void 0, "wait send returns completion response", async (c) => {
3043
3258
  const { client } = await setupDriverTest(c, driverTestConfig);
3044
3259
  const handle = client.queueActor.getOrCreate(["wait-complete"]);
3260
+ const waitTimeout = driverTestConfig.useRealTimers ? 5e3 : 1e3;
3045
3261
  const actionPromise = handle.receiveAndComplete("tasks");
3046
3262
  const result = await handle.send(
3047
3263
  "tasks",
3048
3264
  { value: 123 },
3049
- { wait: true, timeout: 1e3 }
3265
+ { wait: true, timeout: waitTimeout }
3050
3266
  );
3051
3267
  await actionPromise;
3052
3268
  _vitest.expect.call(void 0, result).toEqual({
@@ -3189,7 +3405,7 @@ function runActorRunTests(driverTestConfig) {
3189
3405
  const state1 = await actor.getState();
3190
3406
  _vitest.expect.call(void 0, state1.runStarted).toBe(true);
3191
3407
  const tickCount1 = state1.tickCount;
3192
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.RUN_SLEEP_TIMEOUT + 300);
3408
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.RUN_SLEEP_TIMEOUT + 300);
3193
3409
  const state2 = await actor.getState();
3194
3410
  _vitest.expect.call(void 0, state2.runStarted).toBe(true);
3195
3411
  _vitest.expect.call(void 0, state2.runExited).toBe(false);
@@ -3202,7 +3418,7 @@ function runActorRunTests(driverTestConfig) {
3202
3418
  ]);
3203
3419
  const state = await actor.getState();
3204
3420
  _vitest.expect.call(void 0, state.wakeCount).toBe(1);
3205
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.RUN_SLEEP_TIMEOUT + 300);
3421
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.RUN_SLEEP_TIMEOUT + 300);
3206
3422
  const state2 = await actor.getState();
3207
3423
  _vitest.expect.call(void 0, state2.wakeCount).toBe(2);
3208
3424
  });
@@ -3240,7 +3456,7 @@ function runActorRunTests(driverTestConfig) {
3240
3456
  await waitFor(driverTestConfig, 100);
3241
3457
  const state1 = await actor.getState();
3242
3458
  _vitest.expect.call(void 0, state1.runStarted).toBe(true);
3243
- await waitFor(driverTestConfig, _chunkUZV7NXC6cjs.RUN_SLEEP_TIMEOUT + 500);
3459
+ await waitFor(driverTestConfig, _chunkH5TSEPN4cjs.RUN_SLEEP_TIMEOUT + 500);
3244
3460
  const state2 = await actor.getState();
3245
3461
  _vitest.expect.call(void 0, state2.wakeCount).toBeGreaterThan(state1.wakeCount);
3246
3462
  });
@@ -3396,8 +3612,14 @@ function runActorWorkflowTests(driverTestConfig) {
3396
3612
  const actor = client.workflowCounterActor.getOrCreate([
3397
3613
  "workflow-basic"
3398
3614
  ]);
3399
- await waitFor(driverTestConfig, 1e3);
3400
- const state = await actor.getState();
3615
+ let state = await actor.getState();
3616
+ for (let i = 0; i < 50; i++) {
3617
+ if (state.runCount > 0 && state.history.length > 0 && state.guardTriggered) {
3618
+ break;
3619
+ }
3620
+ await waitFor(driverTestConfig, 100);
3621
+ state = await actor.getState();
3622
+ }
3401
3623
  _vitest.expect.call(void 0, state.runCount).toBeGreaterThan(0);
3402
3624
  _vitest.expect.call(void 0, state.history.length).toBeGreaterThan(0);
3403
3625
  _vitest.expect.call(void 0, state.guardTriggered).toBe(true);
@@ -3405,7 +3627,7 @@ function runActorWorkflowTests(driverTestConfig) {
3405
3627
  _vitest.test.call(void 0, "consumes queue messages via workflow queue.next", async (c) => {
3406
3628
  const { client } = await setupDriverTest(c, driverTestConfig);
3407
3629
  const actor = client.workflowQueueActor.getOrCreate(["workflow-queue"]);
3408
- await actor.send(_chunkUZV7NXC6cjs.WORKFLOW_QUEUE_NAME, {
3630
+ await actor.send(_chunkH5TSEPN4cjs.WORKFLOW_QUEUE_NAME, {
3409
3631
  hello: "world"
3410
3632
  });
3411
3633
  await waitFor(driverTestConfig, 200);
@@ -4784,6 +5006,7 @@ function runDriverTests(driverTestConfigPartial) {
4784
5006
  runActorConnTests(driverTestConfig);
4785
5007
  runActorConnStateTests(driverTestConfig);
4786
5008
  runActorConnHibernationTests(driverTestConfig);
5009
+ runConnErrorSerializationTests(driverTestConfig);
4787
5010
  runActorDbTests(driverTestConfig);
4788
5011
  runActorDestroyTests(driverTestConfig);
4789
5012
  runRequestAccessTests(driverTestConfig);
@@ -4838,7 +5061,7 @@ async function createTestRuntime(registryPath, driverFactory) {
4838
5061
  const parsedConfig = registry.parseConfig();
4839
5062
  const managerDriver = (_a = driver.manager) == null ? void 0 : _a.call(driver, parsedConfig);
4840
5063
  _invariant2.default.call(void 0, managerDriver, "missing manager driver");
4841
- const { router } = _chunkMNS5LY6Mcjs.buildManagerRouter.call(void 0,
5064
+ const { router } = _chunk3B6PCYJBcjs.buildManagerRouter.call(void 0,
4842
5065
  parsedConfig,
4843
5066
  managerDriver,
4844
5067
  () => upgradeWebSocket
@@ -4865,7 +5088,7 @@ async function createTestRuntime(registryPath, driverFactory) {
4865
5088
  _invariant2.default.call(void 0, address && typeof address !== "string", "missing server address");
4866
5089
  const port = address.port;
4867
5090
  const serverEndpoint = `http://127.0.0.1:${port}`;
4868
- _chunkUZV7NXC6cjs.logger.call(void 0, ).info({ msg: "test serer listening", port });
5091
+ _chunkH5TSEPN4cjs.logger.call(void 0, ).info({ msg: "test serer listening", port });
4869
5092
  const cleanup = async () => {
4870
5093
  await new Promise(
4871
5094
  (resolve) => server.close(() => resolve(void 0))