rivetkit 2.0.41 → 2.0.43-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.
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/{chunk-LMG4QMDO.js → chunk-2NJQ3DJ5.js} +15 -5
- package/dist/tsup/{chunk-LMG4QMDO.js.map → chunk-2NJQ3DJ5.js.map} +1 -1
- package/dist/tsup/{chunk-SNAUKDDK.cjs → chunk-2XQS746M.cjs} +4 -4
- package/dist/tsup/chunk-2XQS746M.cjs.map +1 -0
- package/dist/tsup/{chunk-DSNSFYDL.cjs → chunk-3HKN5HQ7.cjs} +3 -3
- package/dist/tsup/chunk-3HKN5HQ7.cjs.map +1 -0
- package/dist/tsup/{chunk-B5UXC4QV.cjs → chunk-BEMEUFS2.cjs} +78 -78
- package/dist/tsup/chunk-BEMEUFS2.cjs.map +1 -0
- package/dist/tsup/chunk-CKBPIXRM.js +278 -0
- package/dist/tsup/chunk-CKBPIXRM.js.map +1 -0
- package/dist/tsup/{chunk-GTQKDCM4.cjs → chunk-ETNL2HZL.cjs} +49 -49
- package/dist/tsup/chunk-ETNL2HZL.cjs.map +1 -0
- package/dist/tsup/{chunk-OXN6EZUB.js → chunk-F7ZL4T63.js} +3 -3
- package/dist/tsup/chunk-GBENOENJ.cjs.map +1 -1
- package/dist/tsup/chunk-KDFWJKMJ.cjs.map +1 -1
- package/dist/tsup/{chunk-2YHR67M4.js → chunk-LFVF5SCU.js} +4 -4
- package/dist/tsup/chunk-LFVF5SCU.js.map +1 -0
- package/dist/tsup/{chunk-4UHJ3ADW.cjs → chunk-MQ3PTGWH.cjs} +115 -99
- package/dist/tsup/chunk-MQ3PTGWH.cjs.map +1 -0
- package/dist/tsup/{chunk-Y7ZDTLD2.js → chunk-NENM5PQN.js} +2 -2
- package/dist/tsup/chunk-R33VIC3W.cjs +278 -0
- package/dist/tsup/chunk-R33VIC3W.cjs.map +1 -0
- package/dist/tsup/{chunk-QDVKDX7G.cjs → chunk-ROVVTBUE.cjs} +9 -9
- package/dist/tsup/chunk-ROVVTBUE.cjs.map +1 -0
- package/dist/tsup/{chunk-7KIR3QLO.js → chunk-S22E2HUH.js} +24 -8
- package/dist/tsup/chunk-S22E2HUH.js.map +1 -0
- package/dist/tsup/{chunk-UGOCTUBG.js → chunk-TFMRMA5S.js} +5 -5
- package/dist/tsup/{chunk-WYZLRPQM.cjs → chunk-YR6H6STI.cjs} +269 -269
- package/dist/tsup/chunk-YR6H6STI.cjs.map +1 -0
- package/dist/tsup/{chunk-S6F7EKC7.cjs → chunk-YZZF7DES.cjs} +20 -10
- package/dist/tsup/chunk-YZZF7DES.cjs.map +1 -0
- package/dist/tsup/{chunk-4J5EFV3E.js → chunk-Z3BORZE2.js} +5 -5
- package/dist/tsup/{chunk-NRP2OHSW.js → chunk-ZKCVZA7Z.js} +5 -5
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.cjs.map +1 -1
- package/dist/tsup/common/log.d.cts +2 -2
- package/dist/tsup/common/log.d.ts +2 -2
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.cjs.map +1 -1
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{config-D43N-CFi.d.ts → config-CLnylLYY.d.ts} +10 -10
- package/dist/tsup/{config-COyis_uH.d.cts → config-CZB2-W8x.d.cts} +10 -10
- package/dist/tsup/{driver-KyM2v645.d.ts → driver-D0QX9M11.d.ts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +4 -4
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +2 -2
- package/dist/tsup/driver-helpers/mod.d.ts +2 -2
- package/dist/tsup/driver-helpers/mod.js +3 -3
- package/dist/tsup/{driver-Bt7B-qMd.d.cts → driver-q-zqG7fc.d.cts} +1 -1
- package/dist/tsup/driver-test-suite/mod.cjs +323 -448
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +2 -2
- package/dist/tsup/driver-test-suite/mod.d.ts +2 -2
- package/dist/tsup/driver-test-suite/mod.js +916 -1041
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/mod.cjs +8 -8
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +7 -7
- package/dist/tsup/serve-test-suite/mod.cjs +1581 -0
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -0
- package/dist/tsup/serve-test-suite/mod.d.cts +9 -0
- package/dist/tsup/serve-test-suite/mod.d.ts +9 -0
- package/dist/tsup/serve-test-suite/mod.js +1578 -0
- package/dist/tsup/serve-test-suite/mod.js.map +1 -0
- package/dist/tsup/test/mod.cjs +8 -8
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +7 -7
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.js +2 -2
- package/package.json +14 -4
- package/src/actor/errors.ts +4 -4
- package/src/driver-test-suite/mod.ts +3 -0
- package/src/driver-test-suite/tests/actor-driver.ts +4 -0
- package/src/driver-test-suite/tests/actor-lifecycle.ts +157 -0
- package/src/driver-test-suite/tests/conn-error-serialization.ts +64 -0
- package/src/drivers/engine/actor-driver.ts +24 -4
- package/src/serve-test-suite/mod.ts +147 -0
- package/dist/schemas/actor-persist/v1.js +0 -167
- package/dist/schemas/actor-persist/v2.js +0 -200
- package/dist/schemas/actor-persist/v3.js +0 -200
- package/dist/schemas/client-protocol/v1.js +0 -301
- package/dist/schemas/client-protocol/v2.js +0 -299
- package/dist/schemas/file-system-driver/v1.js +0 -76
- package/dist/schemas/file-system-driver/v2.js +0 -103
- package/dist/schemas/file-system-driver/v3.js +0 -122
- package/dist/tsup/chunk-2YHR67M4.js.map +0 -1
- package/dist/tsup/chunk-4UHJ3ADW.cjs.map +0 -1
- package/dist/tsup/chunk-7KIR3QLO.js.map +0 -1
- package/dist/tsup/chunk-B5UXC4QV.cjs.map +0 -1
- package/dist/tsup/chunk-DSNSFYDL.cjs.map +0 -1
- package/dist/tsup/chunk-GTQKDCM4.cjs.map +0 -1
- package/dist/tsup/chunk-QDVKDX7G.cjs.map +0 -1
- package/dist/tsup/chunk-S6F7EKC7.cjs.map +0 -1
- package/dist/tsup/chunk-SNAUKDDK.cjs.map +0 -1
- package/dist/tsup/chunk-WYZLRPQM.cjs.map +0 -1
- /package/dist/tsup/{chunk-OXN6EZUB.js.map → chunk-F7ZL4T63.js.map} +0 -0
- /package/dist/tsup/{chunk-Y7ZDTLD2.js.map → chunk-NENM5PQN.js.map} +0 -0
- /package/dist/tsup/{chunk-UGOCTUBG.js.map → chunk-TFMRMA5S.js.map} +0 -0
- /package/dist/tsup/{chunk-4J5EFV3E.js.map → chunk-Z3BORZE2.js.map} +0 -0
- /package/dist/tsup/{chunk-NRP2OHSW.js.map → chunk-ZKCVZA7Z.js.map} +0 -0
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var _chunkQDVKDX7Gcjs = require('../chunk-QDVKDX7G.cjs');
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
var
|
|
7
|
-
require('../chunk-GTQKDCM4.cjs');
|
|
5
|
+
var _chunkR33VIC3Wcjs = require('../chunk-R33VIC3W.cjs');
|
|
8
6
|
|
|
9
7
|
|
|
8
|
+
var _chunkROVVTBUEcjs = require('../chunk-ROVVTBUE.cjs');
|
|
9
|
+
require('../chunk-MQ3PTGWH.cjs');
|
|
10
|
+
require('../chunk-ETNL2HZL.cjs');
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
var _chunkWYZLRPQMcjs = require('../chunk-WYZLRPQM.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkYR6H6STIcjs = require('../chunk-YR6H6STI.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
var _chunk3HKN5HQ7cjs = require('../chunk-3HKN5HQ7.cjs');
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
|
|
@@ -24,17 +25,17 @@ var _chunkDSNSFYDLcjs = require('../chunk-DSNSFYDL.cjs');
|
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
|
|
27
|
-
var _chunkB5UXC4QVcjs = require('../chunk-B5UXC4QV.cjs');
|
|
28
|
-
require('../chunk-KDFWJKMJ.cjs');
|
|
29
28
|
|
|
30
29
|
|
|
30
|
+
var _chunkBEMEUFS2cjs = require('../chunk-BEMEUFS2.cjs');
|
|
31
|
+
require('../chunk-KDFWJKMJ.cjs');
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
var
|
|
34
|
+
var _chunkYZZF7DEScjs = require('../chunk-YZZF7DES.cjs');
|
|
34
35
|
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
var
|
|
38
|
+
var _chunk2XQS746Mcjs = require('../chunk-2XQS746M.cjs');
|
|
38
39
|
require('../chunk-GBENOENJ.cjs');
|
|
39
40
|
|
|
40
41
|
// src/driver-test-suite/mod.ts
|
|
@@ -43,11 +44,6 @@ var _nodews = require('@hono/node-ws');
|
|
|
43
44
|
var _invariant = require('invariant'); var _invariant2 = _interopRequireDefault(_invariant);
|
|
44
45
|
var _vitest = require('vitest');
|
|
45
46
|
|
|
46
|
-
// src/driver-test-suite/log.ts
|
|
47
|
-
function logger() {
|
|
48
|
-
return _chunkS6F7EKC7cjs.getLogger.call(void 0, "test-suite");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
47
|
// src/driver-test-suite/tests/action-features.ts
|
|
52
48
|
|
|
53
49
|
|
|
@@ -84,20 +80,20 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
84
80
|
const oldUrl = new URL(actorRequest.url);
|
|
85
81
|
const normalizedPath = oldUrl.pathname.startsWith("/") ? oldUrl.pathname.slice(1) : oldUrl.pathname;
|
|
86
82
|
const pathWithQuery = normalizedPath + oldUrl.search;
|
|
87
|
-
logger().debug({
|
|
83
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).debug({
|
|
88
84
|
msg: "sending raw http request via test inline driver",
|
|
89
85
|
actorId,
|
|
90
86
|
encoding,
|
|
91
87
|
path: pathWithQuery
|
|
92
88
|
});
|
|
93
89
|
const url = `${endpoint}/.test/inline-driver/send-request/${pathWithQuery}`;
|
|
94
|
-
logger().debug({
|
|
90
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).debug({
|
|
95
91
|
msg: "rewriting http url",
|
|
96
92
|
from: oldUrl,
|
|
97
93
|
to: url
|
|
98
94
|
});
|
|
99
95
|
const headers = new Headers(actorRequest.headers);
|
|
100
|
-
headers.set(
|
|
96
|
+
headers.set(_chunkBEMEUFS2cjs.HEADER_ACTOR_ID, actorId);
|
|
101
97
|
const response = await fetch(
|
|
102
98
|
new Request(url, {
|
|
103
99
|
method: actorRequest.method,
|
|
@@ -113,7 +109,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
113
109
|
const errorData = await clonedResponse.json();
|
|
114
110
|
if (errorData.error) {
|
|
115
111
|
if (typeof errorData.error === "object") {
|
|
116
|
-
throw new (0,
|
|
112
|
+
throw new (0, _chunkYR6H6STIcjs.ActorError)(
|
|
117
113
|
errorData.error.code,
|
|
118
114
|
errorData.error.message,
|
|
119
115
|
errorData.error.metadata
|
|
@@ -121,7 +117,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
121
117
|
}
|
|
122
118
|
}
|
|
123
119
|
} catch (e) {
|
|
124
|
-
if (!(e instanceof
|
|
120
|
+
if (!(e instanceof _chunkYR6H6STIcjs.ActorError)) {
|
|
125
121
|
return response;
|
|
126
122
|
}
|
|
127
123
|
throw e;
|
|
@@ -130,33 +126,33 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
130
126
|
return response;
|
|
131
127
|
},
|
|
132
128
|
async openWebSocket(path, actorId, encoding2, params) {
|
|
133
|
-
const WebSocket2 = await
|
|
129
|
+
const WebSocket2 = await _chunk3HKN5HQ7cjs.importWebSocket.call(void 0, );
|
|
134
130
|
const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
135
131
|
const wsUrl = new URL(
|
|
136
132
|
`${endpoint}/.test/inline-driver/connect-websocket/ws`
|
|
137
133
|
);
|
|
138
|
-
logger().debug({
|
|
134
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).debug({
|
|
139
135
|
msg: "creating websocket connection via test inline driver",
|
|
140
136
|
url: wsUrl.toString()
|
|
141
137
|
});
|
|
142
138
|
const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
143
139
|
const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}`;
|
|
144
140
|
const protocols = [];
|
|
145
|
-
protocols.push(
|
|
146
|
-
protocols.push(`${
|
|
141
|
+
protocols.push(_chunkBEMEUFS2cjs.WS_PROTOCOL_STANDARD);
|
|
142
|
+
protocols.push(`${_chunkBEMEUFS2cjs.WS_PROTOCOL_TARGET}actor`);
|
|
147
143
|
protocols.push(
|
|
148
|
-
`${
|
|
144
|
+
`${_chunkBEMEUFS2cjs.WS_PROTOCOL_ACTOR}${encodeURIComponent(actorId)}`
|
|
149
145
|
);
|
|
150
|
-
protocols.push(`${
|
|
146
|
+
protocols.push(`${_chunkBEMEUFS2cjs.WS_PROTOCOL_ENCODING}${encoding2}`);
|
|
151
147
|
protocols.push(
|
|
152
|
-
`${
|
|
148
|
+
`${_chunkBEMEUFS2cjs.WS_TEST_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
|
|
153
149
|
);
|
|
154
150
|
if (params !== void 0) {
|
|
155
151
|
protocols.push(
|
|
156
|
-
`${
|
|
152
|
+
`${_chunkBEMEUFS2cjs.WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
|
|
157
153
|
);
|
|
158
154
|
}
|
|
159
|
-
logger().debug({
|
|
155
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).debug({
|
|
160
156
|
msg: "connecting to websocket",
|
|
161
157
|
url: finalWsUrl,
|
|
162
158
|
protocols
|
|
@@ -176,7 +172,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
176
172
|
encoding2,
|
|
177
173
|
params
|
|
178
174
|
);
|
|
179
|
-
return upgradeWebSocket(() => wsHandler)(c,
|
|
175
|
+
return upgradeWebSocket(() => wsHandler)(c, _chunkYZZF7DEScjs.noopNext.call(void 0, ));
|
|
180
176
|
},
|
|
181
177
|
async buildGatewayUrl(actorId) {
|
|
182
178
|
return `${endpoint}/gateway/${actorId}`;
|
|
@@ -193,7 +189,7 @@ function createTestInlineClientDriver(endpoint, encoding) {
|
|
|
193
189
|
};
|
|
194
190
|
}
|
|
195
191
|
async function makeInlineRequest(endpoint, encoding, method, args) {
|
|
196
|
-
logger().debug({
|
|
192
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).debug({
|
|
197
193
|
msg: "sending inline request",
|
|
198
194
|
encoding,
|
|
199
195
|
method,
|
|
@@ -223,14 +219,14 @@ async function makeInlineRequest(endpoint, encoding, method, args) {
|
|
|
223
219
|
if ("ok" in callResponse) {
|
|
224
220
|
return callResponse.ok;
|
|
225
221
|
} else if ("err" in callResponse) {
|
|
226
|
-
throw new (0,
|
|
222
|
+
throw new (0, _chunkYR6H6STIcjs.ActorError)(
|
|
227
223
|
callResponse.err.group,
|
|
228
224
|
callResponse.err.code,
|
|
229
225
|
callResponse.err.message,
|
|
230
226
|
callResponse.err.metadata
|
|
231
227
|
);
|
|
232
228
|
} else {
|
|
233
|
-
|
|
229
|
+
_chunkBEMEUFS2cjs.assertUnreachable.call(void 0, callResponse);
|
|
234
230
|
}
|
|
235
231
|
}
|
|
236
232
|
|
|
@@ -243,12 +239,12 @@ async function setupDriverTest(c, driverTestConfig) {
|
|
|
243
239
|
}
|
|
244
240
|
const { endpoint, namespace, runnerName, cleanup } = await driverTestConfig.start();
|
|
245
241
|
c.onTestFinished(() => {
|
|
246
|
-
logger().info("cleaning up test");
|
|
242
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).info("cleaning up test");
|
|
247
243
|
cleanup();
|
|
248
244
|
});
|
|
249
245
|
let client;
|
|
250
246
|
if (driverTestConfig.clientType === "http") {
|
|
251
|
-
client =
|
|
247
|
+
client = _chunkYR6H6STIcjs.createClient.call(void 0, {
|
|
252
248
|
endpoint,
|
|
253
249
|
namespace,
|
|
254
250
|
runnerName,
|
|
@@ -261,12 +257,12 @@ async function setupDriverTest(c, driverTestConfig) {
|
|
|
261
257
|
} else if (driverTestConfig.clientType === "inline") {
|
|
262
258
|
const encoding = _nullishCoalesce(driverTestConfig.encoding, () => ( "bare"));
|
|
263
259
|
const managerDriver = createTestInlineClientDriver(endpoint, encoding);
|
|
264
|
-
const runConfig =
|
|
260
|
+
const runConfig = _chunkYR6H6STIcjs.ClientConfigSchema.parse({
|
|
265
261
|
encoding
|
|
266
262
|
});
|
|
267
|
-
client =
|
|
263
|
+
client = _chunkYR6H6STIcjs.createClientWithDriver.call(void 0, managerDriver, runConfig);
|
|
268
264
|
} else {
|
|
269
|
-
|
|
265
|
+
_chunkBEMEUFS2cjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
|
|
270
266
|
}
|
|
271
267
|
if (!driverTestConfig.HACK_skipCleanupNet) {
|
|
272
268
|
c.onTestFinished(async () => await client.dispose());
|
|
@@ -787,76 +783,6 @@ function runActorConnTests(driverTestConfig) {
|
|
|
787
783
|
|
|
788
784
|
// src/driver-test-suite/tests/actor-conn-hibernation.ts
|
|
789
785
|
|
|
790
|
-
|
|
791
|
-
// fixtures/driver-test-suite/hibernation.ts
|
|
792
|
-
var HIBERNATION_SLEEP_TIMEOUT = 500;
|
|
793
|
-
var hibernationActor = _chunk4UHJ3ADWcjs.actor.call(void 0, {
|
|
794
|
-
state: {
|
|
795
|
-
sleepCount: 0,
|
|
796
|
-
wakeCount: 0
|
|
797
|
-
},
|
|
798
|
-
createConnState: (c) => {
|
|
799
|
-
return {
|
|
800
|
-
count: 0,
|
|
801
|
-
connectCount: 0,
|
|
802
|
-
disconnectCount: 0
|
|
803
|
-
};
|
|
804
|
-
},
|
|
805
|
-
onWake: (c) => {
|
|
806
|
-
c.state.wakeCount += 1;
|
|
807
|
-
},
|
|
808
|
-
onSleep: (c) => {
|
|
809
|
-
c.state.sleepCount += 1;
|
|
810
|
-
},
|
|
811
|
-
onConnect: (c, conn) => {
|
|
812
|
-
conn.state.connectCount += 1;
|
|
813
|
-
},
|
|
814
|
-
onDisconnect: (c, conn) => {
|
|
815
|
-
conn.state.disconnectCount += 1;
|
|
816
|
-
},
|
|
817
|
-
actions: {
|
|
818
|
-
// Basic RPC that returns a simple value
|
|
819
|
-
ping: (c) => {
|
|
820
|
-
return "pong";
|
|
821
|
-
},
|
|
822
|
-
// Increment the connection's count
|
|
823
|
-
connIncrement: (c) => {
|
|
824
|
-
c.conn.state.count += 1;
|
|
825
|
-
return c.conn.state.count;
|
|
826
|
-
},
|
|
827
|
-
// Get the connection's count
|
|
828
|
-
getConnCount: (c) => {
|
|
829
|
-
return c.conn.state.count;
|
|
830
|
-
},
|
|
831
|
-
// Get the connection's lifecycle counts
|
|
832
|
-
getConnLifecycleCounts: (c) => {
|
|
833
|
-
return {
|
|
834
|
-
connectCount: c.conn.state.connectCount,
|
|
835
|
-
disconnectCount: c.conn.state.disconnectCount
|
|
836
|
-
};
|
|
837
|
-
},
|
|
838
|
-
// Get all connection IDs
|
|
839
|
-
getConnectionIds: (c) => {
|
|
840
|
-
return c.conns.entries().map((x) => x[0]).toArray();
|
|
841
|
-
},
|
|
842
|
-
// Get actor sleep/wake counts
|
|
843
|
-
getActorCounts: (c) => {
|
|
844
|
-
return {
|
|
845
|
-
sleepCount: c.state.sleepCount,
|
|
846
|
-
wakeCount: c.state.wakeCount
|
|
847
|
-
};
|
|
848
|
-
},
|
|
849
|
-
// Trigger sleep
|
|
850
|
-
triggerSleep: (c) => {
|
|
851
|
-
c.sleep();
|
|
852
|
-
}
|
|
853
|
-
},
|
|
854
|
-
options: {
|
|
855
|
-
sleepTimeout: HIBERNATION_SLEEP_TIMEOUT
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
// src/driver-test-suite/tests/actor-conn-hibernation.ts
|
|
860
786
|
function runActorConnHibernationTests(driverTestConfig) {
|
|
861
787
|
var _a;
|
|
862
788
|
_vitest.describe.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.hibernation)(
|
|
@@ -870,7 +796,7 @@ function runActorConnHibernationTests(driverTestConfig) {
|
|
|
870
796
|
await hibernatingActor.triggerSleep();
|
|
871
797
|
await waitFor(
|
|
872
798
|
driverTestConfig,
|
|
873
|
-
HIBERNATION_SLEEP_TIMEOUT + 100
|
|
799
|
+
_chunkR33VIC3Wcjs.HIBERNATION_SLEEP_TIMEOUT + 100
|
|
874
800
|
);
|
|
875
801
|
const ping2 = await hibernatingActor.ping();
|
|
876
802
|
_vitest.expect.call(void 0, ping2).toBe("pong");
|
|
@@ -892,7 +818,7 @@ function runActorConnHibernationTests(driverTestConfig) {
|
|
|
892
818
|
await hibernatingActor.triggerSleep();
|
|
893
819
|
await waitFor(
|
|
894
820
|
driverTestConfig,
|
|
895
|
-
HIBERNATION_SLEEP_TIMEOUT + 100
|
|
821
|
+
_chunkR33VIC3Wcjs.HIBERNATION_SLEEP_TIMEOUT + 100
|
|
896
822
|
);
|
|
897
823
|
const count3 = await hibernatingActor.getConnCount();
|
|
898
824
|
_vitest.expect.call(void 0, count3).toBe(2);
|
|
@@ -914,7 +840,7 @@ function runActorConnHibernationTests(driverTestConfig) {
|
|
|
914
840
|
await conn1.triggerSleep();
|
|
915
841
|
await waitFor(
|
|
916
842
|
driverTestConfig,
|
|
917
|
-
HIBERNATION_SLEEP_TIMEOUT + 100
|
|
843
|
+
_chunkR33VIC3Wcjs.HIBERNATION_SLEEP_TIMEOUT + 100
|
|
918
844
|
);
|
|
919
845
|
await conn1.dispose();
|
|
920
846
|
await waitFor(driverTestConfig, 250);
|
|
@@ -1120,6 +1046,44 @@ function runActorConnStateTests(driverTestConfig) {
|
|
|
1120
1046
|
});
|
|
1121
1047
|
}
|
|
1122
1048
|
|
|
1049
|
+
// src/driver-test-suite/tests/conn-error-serialization.ts
|
|
1050
|
+
|
|
1051
|
+
function runConnErrorSerializationTests(driverTestConfig) {
|
|
1052
|
+
_vitest.describe.call(void 0, "Connection Error Serialization Tests", () => {
|
|
1053
|
+
_vitest.test.call(void 0, "error thrown in createConnState preserves group and code through WebSocket serialization", async (c) => {
|
|
1054
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1055
|
+
const actorKey = `test-error-serialization-${Date.now()}`;
|
|
1056
|
+
const actor = client.connErrorSerializationActor.getOrCreate(
|
|
1057
|
+
[actorKey],
|
|
1058
|
+
{ params: { shouldThrow: true } }
|
|
1059
|
+
);
|
|
1060
|
+
const conn = actor.connect();
|
|
1061
|
+
let caughtError;
|
|
1062
|
+
try {
|
|
1063
|
+
await conn.getValue();
|
|
1064
|
+
} catch (err) {
|
|
1065
|
+
caughtError = err;
|
|
1066
|
+
}
|
|
1067
|
+
_vitest.expect.call(void 0, caughtError).toBeDefined();
|
|
1068
|
+
_vitest.expect.call(void 0, caughtError.group).toBe("connection");
|
|
1069
|
+
_vitest.expect.call(void 0, caughtError.code).toBe("custom_error");
|
|
1070
|
+
await conn.dispose();
|
|
1071
|
+
});
|
|
1072
|
+
_vitest.test.call(void 0, "successful createConnState does not throw error", async (c) => {
|
|
1073
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1074
|
+
const actorKey = `test-no-error-${Date.now()}`;
|
|
1075
|
+
const actor = client.connErrorSerializationActor.getOrCreate(
|
|
1076
|
+
[actorKey],
|
|
1077
|
+
{ params: { shouldThrow: false } }
|
|
1078
|
+
);
|
|
1079
|
+
const conn = actor.connect();
|
|
1080
|
+
const value = await conn.getValue();
|
|
1081
|
+
_vitest.expect.call(void 0, value).toBe(0);
|
|
1082
|
+
await conn.dispose();
|
|
1083
|
+
});
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1123
1087
|
// src/driver-test-suite/tests/actor-destroy.ts
|
|
1124
1088
|
|
|
1125
1089
|
function runActorDestroyTests(driverTestConfig) {
|
|
@@ -1308,6 +1272,102 @@ function runActorDestroyTests(driverTestConfig) {
|
|
|
1308
1272
|
// src/driver-test-suite/tests/actor-driver.ts
|
|
1309
1273
|
|
|
1310
1274
|
|
|
1275
|
+
// src/driver-test-suite/tests/actor-lifecycle.ts
|
|
1276
|
+
|
|
1277
|
+
function runActorLifecycleTests(driverTestConfig) {
|
|
1278
|
+
_vitest.describe.call(void 0, "Actor Lifecycle Tests", () => {
|
|
1279
|
+
_vitest.test.call(void 0, "actor stop during start waits for start to complete", async (c) => {
|
|
1280
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1281
|
+
const actorKey = `test-stop-during-start-${Date.now()}`;
|
|
1282
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1283
|
+
const pingPromise = actor.ping();
|
|
1284
|
+
const actorId = await actor.resolve();
|
|
1285
|
+
await actor.destroy();
|
|
1286
|
+
const result = await pingPromise;
|
|
1287
|
+
_vitest.expect.call(void 0, result).toBe("pong");
|
|
1288
|
+
let destroyed = false;
|
|
1289
|
+
try {
|
|
1290
|
+
await client.startStopRaceActor.getForId(actorId).ping();
|
|
1291
|
+
} catch (err) {
|
|
1292
|
+
destroyed = true;
|
|
1293
|
+
_vitest.expect.call(void 0, err.group).toBe("actor");
|
|
1294
|
+
_vitest.expect.call(void 0, err.code).toBe("not_found");
|
|
1295
|
+
}
|
|
1296
|
+
_vitest.expect.call(void 0, destroyed).toBe(true);
|
|
1297
|
+
});
|
|
1298
|
+
_vitest.test.call(void 0, "actor stop before actor instantiation completes cleans up handler", async (c) => {
|
|
1299
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1300
|
+
const actorKey = `test-stop-before-instantiation-${Date.now()}`;
|
|
1301
|
+
const actors = Array.from(
|
|
1302
|
+
{ length: 5 },
|
|
1303
|
+
(_, i) => client.startStopRaceActor.getOrCreate([
|
|
1304
|
+
`${actorKey}-${i}`
|
|
1305
|
+
])
|
|
1306
|
+
);
|
|
1307
|
+
const ids = await Promise.all(actors.map((a) => a.resolve()));
|
|
1308
|
+
await Promise.all(actors.map((a) => a.destroy()));
|
|
1309
|
+
for (const id of ids) {
|
|
1310
|
+
let destroyed = false;
|
|
1311
|
+
try {
|
|
1312
|
+
await client.startStopRaceActor.getForId(id).ping();
|
|
1313
|
+
} catch (err) {
|
|
1314
|
+
destroyed = true;
|
|
1315
|
+
_vitest.expect.call(void 0, err.group).toBe("actor");
|
|
1316
|
+
_vitest.expect.call(void 0, err.code).toBe("not_found");
|
|
1317
|
+
}
|
|
1318
|
+
_vitest.expect.call(void 0, destroyed, `actor ${id} should be destroyed`).toBe(
|
|
1319
|
+
true
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
_vitest.test.call(void 0, "onBeforeActorStart completes before stop proceeds", async (c) => {
|
|
1324
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1325
|
+
const actorKey = `test-before-actor-start-${Date.now()}`;
|
|
1326
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1327
|
+
const statePromise = actor.getState();
|
|
1328
|
+
await actor.destroy();
|
|
1329
|
+
const state = await statePromise;
|
|
1330
|
+
_vitest.expect.call(void 0, state.initialized).toBe(true);
|
|
1331
|
+
_vitest.expect.call(void 0, state.startCompleted).toBe(true);
|
|
1332
|
+
});
|
|
1333
|
+
_vitest.test.call(void 0, "multiple rapid create/destroy cycles handle race correctly", async (c) => {
|
|
1334
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1335
|
+
for (let i = 0; i < 10; i++) {
|
|
1336
|
+
const actorKey = `test-rapid-cycle-${Date.now()}-${i}`;
|
|
1337
|
+
const actor = client.startStopRaceActor.getOrCreate([
|
|
1338
|
+
actorKey
|
|
1339
|
+
]);
|
|
1340
|
+
const resolvePromise = actor.resolve();
|
|
1341
|
+
const destroyPromise = actor.destroy();
|
|
1342
|
+
await Promise.all([resolvePromise, destroyPromise]);
|
|
1343
|
+
}
|
|
1344
|
+
_vitest.expect.call(void 0, true).toBe(true);
|
|
1345
|
+
});
|
|
1346
|
+
_vitest.test.call(void 0, "actor stop called with no actor instance cleans up handler", async (c) => {
|
|
1347
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1348
|
+
const actorKey = `test-cleanup-no-instance-${Date.now()}`;
|
|
1349
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1350
|
+
const id = await actor.resolve();
|
|
1351
|
+
await actor.destroy();
|
|
1352
|
+
const newActor = client.startStopRaceActor.getOrCreate([
|
|
1353
|
+
actorKey
|
|
1354
|
+
]);
|
|
1355
|
+
const result = await newActor.ping();
|
|
1356
|
+
_vitest.expect.call(void 0, result).toBe("pong");
|
|
1357
|
+
await newActor.destroy();
|
|
1358
|
+
});
|
|
1359
|
+
_vitest.test.call(void 0, "onDestroy is called even when actor is destroyed during start", async (c) => {
|
|
1360
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
1361
|
+
const actorKey = `test-ondestroy-during-start-${Date.now()}`;
|
|
1362
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
1363
|
+
const statePromise = actor.getState();
|
|
1364
|
+
await actor.destroy();
|
|
1365
|
+
const state = await statePromise;
|
|
1366
|
+
_vitest.expect.call(void 0, state.destroyCalled).toBe(true);
|
|
1367
|
+
});
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1311
1371
|
// src/driver-test-suite/tests/actor-schedule.ts
|
|
1312
1372
|
|
|
1313
1373
|
function runActorScheduleTests(driverTestConfig) {
|
|
@@ -1370,193 +1430,6 @@ function runActorScheduleTests(driverTestConfig) {
|
|
|
1370
1430
|
|
|
1371
1431
|
// src/driver-test-suite/tests/actor-sleep.ts
|
|
1372
1432
|
|
|
1373
|
-
|
|
1374
|
-
// fixtures/driver-test-suite/sleep.ts
|
|
1375
|
-
var SLEEP_TIMEOUT = 1e3;
|
|
1376
|
-
var sleep = _chunk4UHJ3ADWcjs.actor.call(void 0, {
|
|
1377
|
-
state: { startCount: 0, sleepCount: 0 },
|
|
1378
|
-
onWake: (c) => {
|
|
1379
|
-
c.state.startCount += 1;
|
|
1380
|
-
},
|
|
1381
|
-
onSleep: (c) => {
|
|
1382
|
-
c.state.sleepCount += 1;
|
|
1383
|
-
},
|
|
1384
|
-
actions: {
|
|
1385
|
-
triggerSleep: (c) => {
|
|
1386
|
-
c.sleep();
|
|
1387
|
-
},
|
|
1388
|
-
getCounts: (c) => {
|
|
1389
|
-
return {
|
|
1390
|
-
startCount: c.state.startCount,
|
|
1391
|
-
sleepCount: c.state.sleepCount
|
|
1392
|
-
};
|
|
1393
|
-
},
|
|
1394
|
-
setAlarm: async (c, duration) => {
|
|
1395
|
-
await c.schedule.after(duration, "onAlarm");
|
|
1396
|
-
},
|
|
1397
|
-
onAlarm: (c) => {
|
|
1398
|
-
c.log.info("alarm called");
|
|
1399
|
-
}
|
|
1400
|
-
},
|
|
1401
|
-
options: {
|
|
1402
|
-
sleepTimeout: SLEEP_TIMEOUT
|
|
1403
|
-
}
|
|
1404
|
-
});
|
|
1405
|
-
var sleepWithLongRpc = _chunk4UHJ3ADWcjs.actor.call(void 0, {
|
|
1406
|
-
state: { startCount: 0, sleepCount: 0 },
|
|
1407
|
-
createVars: () => ({}),
|
|
1408
|
-
onWake: (c) => {
|
|
1409
|
-
c.state.startCount += 1;
|
|
1410
|
-
},
|
|
1411
|
-
onSleep: (c) => {
|
|
1412
|
-
c.state.sleepCount += 1;
|
|
1413
|
-
},
|
|
1414
|
-
actions: {
|
|
1415
|
-
getCounts: (c) => {
|
|
1416
|
-
return {
|
|
1417
|
-
startCount: c.state.startCount,
|
|
1418
|
-
sleepCount: c.state.sleepCount
|
|
1419
|
-
};
|
|
1420
|
-
},
|
|
1421
|
-
longRunningRpc: async (c) => {
|
|
1422
|
-
c.log.info("starting long running rpc");
|
|
1423
|
-
c.vars.longRunningResolve = _chunkS6F7EKC7cjs.promiseWithResolvers.call(void 0, );
|
|
1424
|
-
c.broadcast("waiting");
|
|
1425
|
-
await c.vars.longRunningResolve.promise;
|
|
1426
|
-
c.log.info("finished long running rpc");
|
|
1427
|
-
},
|
|
1428
|
-
finishLongRunningRpc: (c) => {
|
|
1429
|
-
var _a;
|
|
1430
|
-
return (_a = c.vars.longRunningResolve) == null ? void 0 : _a.resolve();
|
|
1431
|
-
}
|
|
1432
|
-
},
|
|
1433
|
-
options: {
|
|
1434
|
-
sleepTimeout: SLEEP_TIMEOUT
|
|
1435
|
-
}
|
|
1436
|
-
});
|
|
1437
|
-
var sleepWithRawHttp = _chunk4UHJ3ADWcjs.actor.call(void 0, {
|
|
1438
|
-
state: { startCount: 0, sleepCount: 0, requestCount: 0 },
|
|
1439
|
-
onWake: (c) => {
|
|
1440
|
-
c.state.startCount += 1;
|
|
1441
|
-
},
|
|
1442
|
-
onSleep: (c) => {
|
|
1443
|
-
c.state.sleepCount += 1;
|
|
1444
|
-
},
|
|
1445
|
-
onRequest: async (c, request) => {
|
|
1446
|
-
c.state.requestCount += 1;
|
|
1447
|
-
const url = new URL(request.url);
|
|
1448
|
-
if (url.pathname === "/long-request") {
|
|
1449
|
-
const duration = parseInt(
|
|
1450
|
-
url.searchParams.get("duration") || "1000"
|
|
1451
|
-
);
|
|
1452
|
-
c.log.info({ msg: "starting long fetch request", duration });
|
|
1453
|
-
await new Promise((resolve) => setTimeout(resolve, duration));
|
|
1454
|
-
c.log.info("finished long fetch request");
|
|
1455
|
-
return new Response(JSON.stringify({ completed: true }), {
|
|
1456
|
-
headers: { "Content-Type": "application/json" }
|
|
1457
|
-
});
|
|
1458
|
-
}
|
|
1459
|
-
return new Response("Not Found", { status: 404 });
|
|
1460
|
-
},
|
|
1461
|
-
actions: {
|
|
1462
|
-
getCounts: (c) => {
|
|
1463
|
-
return {
|
|
1464
|
-
startCount: c.state.startCount,
|
|
1465
|
-
sleepCount: c.state.sleepCount,
|
|
1466
|
-
requestCount: c.state.requestCount
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
},
|
|
1470
|
-
options: {
|
|
1471
|
-
sleepTimeout: SLEEP_TIMEOUT
|
|
1472
|
-
}
|
|
1473
|
-
});
|
|
1474
|
-
var sleepWithRawWebSocket = _chunk4UHJ3ADWcjs.actor.call(void 0, {
|
|
1475
|
-
state: { startCount: 0, sleepCount: 0, connectionCount: 0 },
|
|
1476
|
-
onWake: (c) => {
|
|
1477
|
-
c.state.startCount += 1;
|
|
1478
|
-
},
|
|
1479
|
-
onSleep: (c) => {
|
|
1480
|
-
c.state.sleepCount += 1;
|
|
1481
|
-
},
|
|
1482
|
-
onWebSocket: (c, websocket) => {
|
|
1483
|
-
c.state.connectionCount += 1;
|
|
1484
|
-
c.log.info({
|
|
1485
|
-
msg: "websocket connected",
|
|
1486
|
-
connectionCount: c.state.connectionCount
|
|
1487
|
-
});
|
|
1488
|
-
websocket.send(
|
|
1489
|
-
JSON.stringify({
|
|
1490
|
-
type: "connected",
|
|
1491
|
-
connectionCount: c.state.connectionCount
|
|
1492
|
-
})
|
|
1493
|
-
);
|
|
1494
|
-
websocket.addEventListener("message", (event) => {
|
|
1495
|
-
const data = event.data;
|
|
1496
|
-
if (typeof data === "string") {
|
|
1497
|
-
try {
|
|
1498
|
-
const parsed = JSON.parse(data);
|
|
1499
|
-
if (parsed.type === "getCounts") {
|
|
1500
|
-
websocket.send(
|
|
1501
|
-
JSON.stringify({
|
|
1502
|
-
type: "counts",
|
|
1503
|
-
startCount: c.state.startCount,
|
|
1504
|
-
sleepCount: c.state.sleepCount,
|
|
1505
|
-
connectionCount: c.state.connectionCount
|
|
1506
|
-
})
|
|
1507
|
-
);
|
|
1508
|
-
} else if (parsed.type === "keepAlive") {
|
|
1509
|
-
websocket.send(JSON.stringify({ type: "ack" }));
|
|
1510
|
-
}
|
|
1511
|
-
} catch (e2) {
|
|
1512
|
-
websocket.send(data);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
});
|
|
1516
|
-
websocket.addEventListener("close", () => {
|
|
1517
|
-
c.state.connectionCount -= 1;
|
|
1518
|
-
c.log.info({
|
|
1519
|
-
msg: "websocket disconnected",
|
|
1520
|
-
connectionCount: c.state.connectionCount
|
|
1521
|
-
});
|
|
1522
|
-
});
|
|
1523
|
-
},
|
|
1524
|
-
actions: {
|
|
1525
|
-
getCounts: (c) => {
|
|
1526
|
-
return {
|
|
1527
|
-
startCount: c.state.startCount,
|
|
1528
|
-
sleepCount: c.state.sleepCount,
|
|
1529
|
-
connectionCount: c.state.connectionCount
|
|
1530
|
-
};
|
|
1531
|
-
}
|
|
1532
|
-
},
|
|
1533
|
-
options: {
|
|
1534
|
-
sleepTimeout: SLEEP_TIMEOUT
|
|
1535
|
-
}
|
|
1536
|
-
});
|
|
1537
|
-
var sleepWithNoSleepOption = _chunk4UHJ3ADWcjs.actor.call(void 0, {
|
|
1538
|
-
state: { startCount: 0, sleepCount: 0 },
|
|
1539
|
-
onWake: (c) => {
|
|
1540
|
-
c.state.startCount += 1;
|
|
1541
|
-
},
|
|
1542
|
-
onSleep: (c) => {
|
|
1543
|
-
c.state.sleepCount += 1;
|
|
1544
|
-
},
|
|
1545
|
-
actions: {
|
|
1546
|
-
getCounts: (c) => {
|
|
1547
|
-
return {
|
|
1548
|
-
startCount: c.state.startCount,
|
|
1549
|
-
sleepCount: c.state.sleepCount
|
|
1550
|
-
};
|
|
1551
|
-
}
|
|
1552
|
-
},
|
|
1553
|
-
options: {
|
|
1554
|
-
sleepTimeout: SLEEP_TIMEOUT,
|
|
1555
|
-
noSleep: true
|
|
1556
|
-
}
|
|
1557
|
-
});
|
|
1558
|
-
|
|
1559
|
-
// src/driver-test-suite/tests/actor-sleep.ts
|
|
1560
1433
|
function runActorSleepTests(driverTestConfig) {
|
|
1561
1434
|
var _a;
|
|
1562
1435
|
_vitest.describe.skipIf((_a = driverTestConfig.skip) == null ? void 0 : _a.sleep)("Actor Sleep Tests", () => {
|
|
@@ -1586,7 +1459,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1586
1459
|
}
|
|
1587
1460
|
await sleepActor.triggerSleep();
|
|
1588
1461
|
await sleepActor.dispose();
|
|
1589
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1462
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1590
1463
|
const sleepActor2 = client.sleep.getOrCreate();
|
|
1591
1464
|
{
|
|
1592
1465
|
const { startCount, sleepCount } = await sleepActor2.getCounts();
|
|
@@ -1602,7 +1475,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1602
1475
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1603
1476
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1604
1477
|
}
|
|
1605
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1478
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1606
1479
|
{
|
|
1607
1480
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1608
1481
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1618,7 +1491,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1618
1491
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1619
1492
|
}
|
|
1620
1493
|
await sleepActor.dispose();
|
|
1621
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1494
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1622
1495
|
const sleepActor2 = client.sleep.getOrCreate();
|
|
1623
1496
|
{
|
|
1624
1497
|
const { startCount, sleepCount } = await sleepActor2.getCounts();
|
|
@@ -1634,19 +1507,19 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1634
1507
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1635
1508
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1636
1509
|
}
|
|
1637
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT - 250);
|
|
1510
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT - 250);
|
|
1638
1511
|
{
|
|
1639
1512
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1640
1513
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1641
1514
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1642
1515
|
}
|
|
1643
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT - 250);
|
|
1516
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT - 250);
|
|
1644
1517
|
{
|
|
1645
1518
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1646
1519
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1647
1520
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1648
1521
|
}
|
|
1649
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1522
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1650
1523
|
{
|
|
1651
1524
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1652
1525
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1661,8 +1534,8 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1661
1534
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1662
1535
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1663
1536
|
}
|
|
1664
|
-
await sleepActor.setAlarm(SLEEP_TIMEOUT - 250);
|
|
1665
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1537
|
+
await sleepActor.setAlarm(_chunkR33VIC3Wcjs.SLEEP_TIMEOUT - 250);
|
|
1538
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1666
1539
|
{
|
|
1667
1540
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1668
1541
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
@@ -1677,8 +1550,8 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1677
1550
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1678
1551
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1679
1552
|
}
|
|
1680
|
-
await sleepActor.setAlarm(SLEEP_TIMEOUT + 250);
|
|
1681
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 200);
|
|
1553
|
+
await sleepActor.setAlarm(_chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1554
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 200);
|
|
1682
1555
|
{
|
|
1683
1556
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1684
1557
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1698,7 +1571,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1698
1571
|
);
|
|
1699
1572
|
const longRunningPromise = sleepActor.longRunningRpc();
|
|
1700
1573
|
await waitPromise;
|
|
1701
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1574
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1702
1575
|
await sleepActor.finishLongRunningRpc();
|
|
1703
1576
|
await longRunningPromise;
|
|
1704
1577
|
{
|
|
@@ -1707,7 +1580,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1707
1580
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1708
1581
|
}
|
|
1709
1582
|
await sleepActor.dispose();
|
|
1710
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1583
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1711
1584
|
const sleepActor2 = client.sleepWithLongRpc.getOrCreate();
|
|
1712
1585
|
{
|
|
1713
1586
|
const { startCount, sleepCount } = await sleepActor2.getCounts();
|
|
@@ -1739,7 +1612,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1739
1612
|
}
|
|
1740
1613
|
};
|
|
1741
1614
|
});
|
|
1742
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1615
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1743
1616
|
ws.send(JSON.stringify({ type: "getCounts" }));
|
|
1744
1617
|
const counts = await new Promise((resolve) => {
|
|
1745
1618
|
ws.onmessage = (event) => {
|
|
@@ -1752,7 +1625,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1752
1625
|
_vitest.expect.call(void 0, counts.sleepCount).toBe(0);
|
|
1753
1626
|
_vitest.expect.call(void 0, counts.startCount).toBe(1);
|
|
1754
1627
|
ws.close();
|
|
1755
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1628
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1756
1629
|
{
|
|
1757
1630
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1758
1631
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1770,7 +1643,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1770
1643
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1771
1644
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1772
1645
|
}
|
|
1773
|
-
const fetchDuration = SLEEP_TIMEOUT + 250;
|
|
1646
|
+
const fetchDuration = _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250;
|
|
1774
1647
|
const fetchPromise = sleepActor.fetch(
|
|
1775
1648
|
`long-request?duration=${fetchDuration}`
|
|
1776
1649
|
);
|
|
@@ -1783,7 +1656,7 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1783
1656
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1784
1657
|
_vitest.expect.call(void 0, requestCount).toBe(1);
|
|
1785
1658
|
}
|
|
1786
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1659
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1787
1660
|
{
|
|
1788
1661
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1789
1662
|
_vitest.expect.call(void 0, sleepCount).toBe(1);
|
|
@@ -1798,13 +1671,13 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1798
1671
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1799
1672
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1800
1673
|
}
|
|
1801
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1674
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1802
1675
|
{
|
|
1803
1676
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1804
1677
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
1805
1678
|
_vitest.expect.call(void 0, startCount).toBe(1);
|
|
1806
1679
|
}
|
|
1807
|
-
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 250);
|
|
1680
|
+
await waitFor(driverTestConfig, _chunkR33VIC3Wcjs.SLEEP_TIMEOUT + 250);
|
|
1808
1681
|
{
|
|
1809
1682
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
1810
1683
|
_vitest.expect.call(void 0, sleepCount).toBe(0);
|
|
@@ -1857,6 +1730,7 @@ function runActorDriverTests(driverTestConfig) {
|
|
|
1857
1730
|
runActorStateTests(driverTestConfig);
|
|
1858
1731
|
runActorScheduleTests(driverTestConfig);
|
|
1859
1732
|
runActorSleepTests(driverTestConfig);
|
|
1733
|
+
runActorLifecycleTests(driverTestConfig);
|
|
1860
1734
|
});
|
|
1861
1735
|
}
|
|
1862
1736
|
|
|
@@ -1900,8 +1774,8 @@ function runActorErrorHandlingTests(driverTestConfig) {
|
|
|
1900
1774
|
await handle.throwInternalError();
|
|
1901
1775
|
_vitest.expect.call(void 0, true).toBe(false);
|
|
1902
1776
|
} catch (error) {
|
|
1903
|
-
_vitest.expect.call(void 0, error.code).toBe(
|
|
1904
|
-
_vitest.expect.call(void 0, error.message).toBe(
|
|
1777
|
+
_vitest.expect.call(void 0, error.code).toBe(_chunk2XQS746Mcjs.INTERNAL_ERROR_CODE);
|
|
1778
|
+
_vitest.expect.call(void 0, error.message).toBe(_chunk2XQS746Mcjs.INTERNAL_ERROR_DESCRIPTION);
|
|
1905
1779
|
}
|
|
1906
1780
|
});
|
|
1907
1781
|
});
|
|
@@ -2384,50 +2258,50 @@ function runActorOnStateChangeTests(driverTestConfig) {
|
|
|
2384
2258
|
_vitest.describe.call(void 0, "Actor onStateChange Tests", () => {
|
|
2385
2259
|
_vitest.test.call(void 0, "triggers onStateChange when state is modified", async (c) => {
|
|
2386
2260
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2387
|
-
const
|
|
2388
|
-
await
|
|
2389
|
-
const changeCount = await
|
|
2261
|
+
const actor = client.onStateChangeActor.getOrCreate();
|
|
2262
|
+
await actor.setValue(10);
|
|
2263
|
+
const changeCount = await actor.getChangeCount();
|
|
2390
2264
|
_vitest.expect.call(void 0, changeCount).toBe(1);
|
|
2391
2265
|
});
|
|
2392
2266
|
_vitest.test.call(void 0, "triggers onChange multiple times for multiple state changes", async (c) => {
|
|
2393
2267
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2394
|
-
const
|
|
2395
|
-
await
|
|
2396
|
-
const changeCount = await
|
|
2268
|
+
const actor = client.onStateChangeActor.getOrCreate();
|
|
2269
|
+
await actor.incrementMultiple(3);
|
|
2270
|
+
const changeCount = await actor.getChangeCount();
|
|
2397
2271
|
_vitest.expect.call(void 0, changeCount).toBe(3);
|
|
2398
2272
|
});
|
|
2399
2273
|
_vitest.test.call(void 0, "does NOT trigger onChange for read-only actions", async (c) => {
|
|
2400
2274
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2401
|
-
const
|
|
2402
|
-
await
|
|
2403
|
-
const value = await
|
|
2275
|
+
const actor = client.onStateChangeActor.getOrCreate();
|
|
2276
|
+
await actor.setValue(5);
|
|
2277
|
+
const value = await actor.getValue();
|
|
2404
2278
|
_vitest.expect.call(void 0, value).toBe(5);
|
|
2405
|
-
const changeCount = await
|
|
2279
|
+
const changeCount = await actor.getChangeCount();
|
|
2406
2280
|
_vitest.expect.call(void 0, changeCount).toBe(1);
|
|
2407
2281
|
});
|
|
2408
2282
|
_vitest.test.call(void 0, "does NOT trigger onChange for computed values", async (c) => {
|
|
2409
2283
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2410
|
-
const
|
|
2411
|
-
await
|
|
2284
|
+
const actor = client.onStateChangeActor.getOrCreate();
|
|
2285
|
+
await actor.setValue(3);
|
|
2412
2286
|
{
|
|
2413
|
-
const changeCount = await
|
|
2287
|
+
const changeCount = await actor.getChangeCount();
|
|
2414
2288
|
_vitest.expect.call(void 0, changeCount).toBe(1);
|
|
2415
2289
|
}
|
|
2416
|
-
const doubled = await
|
|
2290
|
+
const doubled = await actor.getDoubled();
|
|
2417
2291
|
_vitest.expect.call(void 0, doubled).toBe(6);
|
|
2418
2292
|
{
|
|
2419
|
-
const changeCount = await
|
|
2293
|
+
const changeCount = await actor.getChangeCount();
|
|
2420
2294
|
_vitest.expect.call(void 0, changeCount).toBe(1);
|
|
2421
2295
|
}
|
|
2422
2296
|
});
|
|
2423
2297
|
_vitest.test.call(void 0, "simple: connect, call action, dispose does NOT trigger onChange", async (c) => {
|
|
2424
2298
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2425
|
-
const
|
|
2426
|
-
const connection = await
|
|
2299
|
+
const actor = client.onStateChangeActor.getOrCreate();
|
|
2300
|
+
const connection = await actor.connect();
|
|
2427
2301
|
const value = await connection.getValue();
|
|
2428
2302
|
_vitest.expect.call(void 0, value).toBe(0);
|
|
2429
2303
|
await connection.dispose();
|
|
2430
|
-
const changeCount = await
|
|
2304
|
+
const changeCount = await actor.getChangeCount();
|
|
2431
2305
|
_vitest.expect.call(void 0, changeCount).toBe(0);
|
|
2432
2306
|
});
|
|
2433
2307
|
});
|
|
@@ -2581,17 +2455,17 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2581
2455
|
value: 42,
|
|
2582
2456
|
nested: { foo: "bar" }
|
|
2583
2457
|
};
|
|
2584
|
-
const
|
|
2458
|
+
const actor = await client.inputActor.create(void 0, {
|
|
2585
2459
|
input: testInput
|
|
2586
2460
|
});
|
|
2587
|
-
const inputs = await
|
|
2461
|
+
const inputs = await actor.getInputs();
|
|
2588
2462
|
_vitest.expect.call(void 0, inputs.initialInput).toEqual(testInput);
|
|
2589
2463
|
_vitest.expect.call(void 0, inputs.onCreateInput).toEqual(testInput);
|
|
2590
2464
|
});
|
|
2591
2465
|
_vitest.test.call(void 0, "input is undefined when not provided", async (c) => {
|
|
2592
2466
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2593
|
-
const
|
|
2594
|
-
const inputs = await
|
|
2467
|
+
const actor = await client.inputActor.create();
|
|
2468
|
+
const inputs = await actor.getInputs();
|
|
2595
2469
|
_vitest.expect.call(void 0, inputs.initialInput).toBeUndefined();
|
|
2596
2470
|
_vitest.expect.call(void 0, inputs.onCreateInput).toBeUndefined();
|
|
2597
2471
|
});
|
|
@@ -2603,10 +2477,10 @@ function runManagerDriverTests(driverTestConfig) {
|
|
|
2603
2477
|
value: 100,
|
|
2604
2478
|
nested: { baz: "qux" }
|
|
2605
2479
|
};
|
|
2606
|
-
const
|
|
2480
|
+
const actor = client.inputActor.getOrCreate(uniqueKey, {
|
|
2607
2481
|
createWithInput: testInput
|
|
2608
2482
|
});
|
|
2609
|
-
const inputs = await
|
|
2483
|
+
const inputs = await actor.getInputs();
|
|
2610
2484
|
_vitest.expect.call(void 0, inputs.initialInput).toEqual(testInput);
|
|
2611
2485
|
_vitest.expect.call(void 0, inputs.onCreateInput).toEqual(testInput);
|
|
2612
2486
|
const existingActor = client.inputActor.getOrCreate(uniqueKey);
|
|
@@ -2721,17 +2595,17 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2721
2595
|
_vitest.describe.call(void 0, "raw http", () => {
|
|
2722
2596
|
_vitest.test.call(void 0, "should handle raw HTTP GET requests", async (c) => {
|
|
2723
2597
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2724
|
-
const
|
|
2725
|
-
const helloResponse = await
|
|
2598
|
+
const actor = client.rawHttpActor.getOrCreate(["test"]);
|
|
2599
|
+
const helloResponse = await actor.fetch("api/hello");
|
|
2726
2600
|
_vitest.expect.call(void 0, helloResponse.ok).toBe(true);
|
|
2727
2601
|
const helloData = await helloResponse.json();
|
|
2728
2602
|
_vitest.expect.call(void 0, helloData).toEqual({ message: "Hello from actor!" });
|
|
2729
2603
|
});
|
|
2730
2604
|
_vitest.test.call(void 0, "should handle raw HTTP POST requests with echo", async (c) => {
|
|
2731
2605
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2732
|
-
const
|
|
2606
|
+
const actor = client.rawHttpActor.getOrCreate(["test"]);
|
|
2733
2607
|
const testData = { test: "data", number: 123 };
|
|
2734
|
-
const echoResponse = await
|
|
2608
|
+
const echoResponse = await actor.fetch("api/echo", {
|
|
2735
2609
|
method: "POST",
|
|
2736
2610
|
headers: {
|
|
2737
2611
|
"Content-Type": "application/json"
|
|
@@ -2744,23 +2618,23 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2744
2618
|
});
|
|
2745
2619
|
_vitest.test.call(void 0, "should track state across raw HTTP requests", async (c) => {
|
|
2746
2620
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2747
|
-
const
|
|
2748
|
-
await
|
|
2749
|
-
await
|
|
2750
|
-
await
|
|
2751
|
-
const stateResponse = await
|
|
2621
|
+
const actor = client.rawHttpActor.getOrCreate(["state-test"]);
|
|
2622
|
+
await actor.fetch("api/hello");
|
|
2623
|
+
await actor.fetch("api/hello");
|
|
2624
|
+
await actor.fetch("api/state");
|
|
2625
|
+
const stateResponse = await actor.fetch("api/state");
|
|
2752
2626
|
_vitest.expect.call(void 0, stateResponse.ok).toBe(true);
|
|
2753
2627
|
const stateData = await stateResponse.json();
|
|
2754
2628
|
_vitest.expect.call(void 0, stateData.requestCount).toBe(4);
|
|
2755
2629
|
});
|
|
2756
2630
|
_vitest.test.call(void 0, "should pass headers correctly", async (c) => {
|
|
2757
2631
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2758
|
-
const
|
|
2632
|
+
const actor = client.rawHttpActor.getOrCreate(["headers-test"]);
|
|
2759
2633
|
const customHeaders = {
|
|
2760
2634
|
"X-Custom-Header": "test-value",
|
|
2761
2635
|
"X-Another-Header": "another-value"
|
|
2762
2636
|
};
|
|
2763
|
-
const response = await
|
|
2637
|
+
const response = await actor.fetch("api/headers", {
|
|
2764
2638
|
headers: customHeaders
|
|
2765
2639
|
});
|
|
2766
2640
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
@@ -2770,26 +2644,26 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2770
2644
|
});
|
|
2771
2645
|
_vitest.test.call(void 0, "should return 404 for unhandled paths", async (c) => {
|
|
2772
2646
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2773
|
-
const
|
|
2774
|
-
const response = await
|
|
2647
|
+
const actor = client.rawHttpActor.getOrCreate(["404-test"]);
|
|
2648
|
+
const response = await actor.fetch("api/nonexistent");
|
|
2775
2649
|
_vitest.expect.call(void 0, response.ok).toBe(false);
|
|
2776
2650
|
_vitest.expect.call(void 0, response.status).toBe(404);
|
|
2777
2651
|
});
|
|
2778
2652
|
_vitest.test.call(void 0, "should return 404 when no onRequest handler defined", async (c) => {
|
|
2779
2653
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2780
|
-
const
|
|
2654
|
+
const actor = client.rawHttpNoHandlerActor.getOrCreate([
|
|
2781
2655
|
"no-handler"
|
|
2782
2656
|
]);
|
|
2783
|
-
const response = await
|
|
2657
|
+
const response = await actor.fetch("api/anything");
|
|
2784
2658
|
_vitest.expect.call(void 0, response.ok).toBe(false);
|
|
2785
2659
|
_vitest.expect.call(void 0, response.status).toBe(404);
|
|
2786
2660
|
});
|
|
2787
2661
|
_vitest.test.call(void 0, "should return 500 error when onRequest returns void", async (c) => {
|
|
2788
2662
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2789
|
-
const
|
|
2663
|
+
const actor = client.rawHttpVoidReturnActor.getOrCreate([
|
|
2790
2664
|
"void-return"
|
|
2791
2665
|
]);
|
|
2792
|
-
const response = await
|
|
2666
|
+
const response = await actor.fetch("api/anything");
|
|
2793
2667
|
_vitest.expect.call(void 0, response.ok).toBe(false);
|
|
2794
2668
|
_vitest.expect.call(void 0, response.status).toBe(500);
|
|
2795
2669
|
try {
|
|
@@ -2797,15 +2671,15 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2797
2671
|
_vitest.expect.call(void 0, errorData.message).toContain(
|
|
2798
2672
|
"onRequest handler must return a Response"
|
|
2799
2673
|
);
|
|
2800
|
-
} catch (
|
|
2674
|
+
} catch (e2) {
|
|
2801
2675
|
}
|
|
2802
2676
|
});
|
|
2803
2677
|
_vitest.test.call(void 0, "should handle different HTTP methods", async (c) => {
|
|
2804
2678
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2805
|
-
const
|
|
2679
|
+
const actor = client.rawHttpActor.getOrCreate(["methods-test"]);
|
|
2806
2680
|
const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
2807
2681
|
for (const method of methods) {
|
|
2808
|
-
const response = await
|
|
2682
|
+
const response = await actor.fetch("api/echo", {
|
|
2809
2683
|
method,
|
|
2810
2684
|
body: ["POST", "PUT", "PATCH"].includes(method) ? JSON.stringify({ method }) : void 0
|
|
2811
2685
|
});
|
|
@@ -2822,9 +2696,9 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2822
2696
|
});
|
|
2823
2697
|
_vitest.test.call(void 0, "should handle binary data", async (c) => {
|
|
2824
2698
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2825
|
-
const
|
|
2699
|
+
const actor = client.rawHttpActor.getOrCreate(["binary-test"]);
|
|
2826
2700
|
const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
2827
|
-
const response = await
|
|
2701
|
+
const response = await actor.fetch("api/echo", {
|
|
2828
2702
|
method: "POST",
|
|
2829
2703
|
headers: {
|
|
2830
2704
|
"Content-Type": "application/octet-stream"
|
|
@@ -2838,24 +2712,24 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2838
2712
|
});
|
|
2839
2713
|
_vitest.test.call(void 0, "should work with Hono router using createVars", async (c) => {
|
|
2840
2714
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2841
|
-
const
|
|
2842
|
-
const rootResponse = await
|
|
2715
|
+
const actor = client.rawHttpHonoActor.getOrCreate(["hono-test"]);
|
|
2716
|
+
const rootResponse = await actor.fetch("/");
|
|
2843
2717
|
_vitest.expect.call(void 0, rootResponse.ok).toBe(true);
|
|
2844
2718
|
const rootData = await rootResponse.json();
|
|
2845
2719
|
_vitest.expect.call(void 0, rootData).toEqual({ message: "Welcome to Hono actor!" });
|
|
2846
|
-
const usersResponse = await
|
|
2720
|
+
const usersResponse = await actor.fetch("/users");
|
|
2847
2721
|
_vitest.expect.call(void 0, usersResponse.ok).toBe(true);
|
|
2848
2722
|
const users = await usersResponse.json();
|
|
2849
2723
|
_vitest.expect.call(void 0, users).toEqual([
|
|
2850
2724
|
{ id: 1, name: "Alice" },
|
|
2851
2725
|
{ id: 2, name: "Bob" }
|
|
2852
2726
|
]);
|
|
2853
|
-
const userResponse = await
|
|
2727
|
+
const userResponse = await actor.fetch("/users/1");
|
|
2854
2728
|
_vitest.expect.call(void 0, userResponse.ok).toBe(true);
|
|
2855
2729
|
const user = await userResponse.json();
|
|
2856
2730
|
_vitest.expect.call(void 0, user).toEqual({ id: 1, name: "Alice" });
|
|
2857
2731
|
const newUser = { name: "Charlie" };
|
|
2858
|
-
const createResponse = await
|
|
2732
|
+
const createResponse = await actor.fetch("/users", {
|
|
2859
2733
|
method: "POST",
|
|
2860
2734
|
headers: { "Content-Type": "application/json" },
|
|
2861
2735
|
body: JSON.stringify(newUser)
|
|
@@ -2865,7 +2739,7 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2865
2739
|
const createdUser = await createResponse.json();
|
|
2866
2740
|
_vitest.expect.call(void 0, createdUser).toEqual({ id: 3, name: "Charlie" });
|
|
2867
2741
|
const updateData = { name: "Alice Updated" };
|
|
2868
|
-
const updateResponse = await
|
|
2742
|
+
const updateResponse = await actor.fetch("/users/1", {
|
|
2869
2743
|
method: "PUT",
|
|
2870
2744
|
headers: { "Content-Type": "application/json" },
|
|
2871
2745
|
body: JSON.stringify(updateData)
|
|
@@ -2873,32 +2747,32 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2873
2747
|
_vitest.expect.call(void 0, updateResponse.ok).toBe(true);
|
|
2874
2748
|
const updatedUser = await updateResponse.json();
|
|
2875
2749
|
_vitest.expect.call(void 0, updatedUser).toEqual({ id: 1, name: "Alice Updated" });
|
|
2876
|
-
const deleteResponse = await
|
|
2750
|
+
const deleteResponse = await actor.fetch("/users/2", {
|
|
2877
2751
|
method: "DELETE"
|
|
2878
2752
|
});
|
|
2879
2753
|
_vitest.expect.call(void 0, deleteResponse.ok).toBe(true);
|
|
2880
2754
|
const deleteResult = await deleteResponse.json();
|
|
2881
2755
|
_vitest.expect.call(void 0, deleteResult).toEqual({ message: "User 2 deleted" });
|
|
2882
|
-
const notFoundResponse = await
|
|
2756
|
+
const notFoundResponse = await actor.fetch("/api/unknown");
|
|
2883
2757
|
_vitest.expect.call(void 0, notFoundResponse.ok).toBe(false);
|
|
2884
2758
|
_vitest.expect.call(void 0, notFoundResponse.status).toBe(404);
|
|
2885
2759
|
});
|
|
2886
2760
|
_vitest.test.call(void 0, "should handle paths with and without leading slashes", async (c) => {
|
|
2887
2761
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2888
|
-
const
|
|
2889
|
-
const responseWithoutSlash = await
|
|
2762
|
+
const actor = client.rawHttpActor.getOrCreate(["path-test"]);
|
|
2763
|
+
const responseWithoutSlash = await actor.fetch("api/hello");
|
|
2890
2764
|
_vitest.expect.call(void 0, responseWithoutSlash.ok).toBe(true);
|
|
2891
2765
|
const dataWithoutSlash = await responseWithoutSlash.json();
|
|
2892
2766
|
_vitest.expect.call(void 0, dataWithoutSlash).toEqual({ message: "Hello from actor!" });
|
|
2893
|
-
const responseWithSlash = await
|
|
2767
|
+
const responseWithSlash = await actor.fetch("/api/hello");
|
|
2894
2768
|
_vitest.expect.call(void 0, responseWithSlash.ok).toBe(true);
|
|
2895
2769
|
const dataWithSlash = await responseWithSlash.json();
|
|
2896
2770
|
_vitest.expect.call(void 0, dataWithSlash).toEqual({ message: "Hello from actor!" });
|
|
2897
2771
|
});
|
|
2898
2772
|
_vitest.test.call(void 0, "should not create double slashes in request URLs", async (c) => {
|
|
2899
2773
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2900
|
-
const
|
|
2901
|
-
const response = await
|
|
2774
|
+
const actor = client.rawHttpHonoActor.getOrCreate(["url-test"]);
|
|
2775
|
+
const response = await actor.fetch("/users");
|
|
2902
2776
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
2903
2777
|
const data = await response.json();
|
|
2904
2778
|
_vitest.expect.call(void 0, data).toEqual([
|
|
@@ -2908,13 +2782,13 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2908
2782
|
});
|
|
2909
2783
|
_vitest.test.call(void 0, "should handle forwarded requests correctly without double slashes", async (c) => {
|
|
2910
2784
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2911
|
-
const
|
|
2785
|
+
const actor = client.rawHttpHonoActor.getOrCreate(["forward-test"]);
|
|
2912
2786
|
const truncatedPath = "/users";
|
|
2913
2787
|
const url = new URL(truncatedPath, "http://example.com");
|
|
2914
2788
|
const newRequest = new Request(url, {
|
|
2915
2789
|
method: "GET"
|
|
2916
2790
|
});
|
|
2917
|
-
const response = await
|
|
2791
|
+
const response = await actor.fetch(
|
|
2918
2792
|
truncatedPath,
|
|
2919
2793
|
newRequest
|
|
2920
2794
|
);
|
|
@@ -2927,22 +2801,22 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2927
2801
|
});
|
|
2928
2802
|
_vitest.test.call(void 0, "example fix: should properly forward requests using just Request object", async (c) => {
|
|
2929
2803
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2930
|
-
const
|
|
2804
|
+
const actor = client.rawHttpHonoActor.getOrCreate(["forward-fix"]);
|
|
2931
2805
|
const truncatedPath = "/users/1";
|
|
2932
2806
|
const url = new URL(truncatedPath, "http://example.com");
|
|
2933
2807
|
const newRequest = new Request(url, {
|
|
2934
2808
|
method: "GET"
|
|
2935
2809
|
});
|
|
2936
|
-
const response = await
|
|
2810
|
+
const response = await actor.fetch(newRequest);
|
|
2937
2811
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
2938
2812
|
const user = await response.json();
|
|
2939
2813
|
_vitest.expect.call(void 0, user).toEqual({ id: 1, name: "Alice" });
|
|
2940
2814
|
});
|
|
2941
2815
|
_vitest.test.call(void 0, "should support standard fetch API with URL and Request objects", async (c) => {
|
|
2942
2816
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2943
|
-
const
|
|
2817
|
+
const actor = client.rawHttpActor.getOrCreate(["fetch-api-test"]);
|
|
2944
2818
|
const url = new URL("/api/echo", "http://example.com");
|
|
2945
|
-
const urlResponse = await
|
|
2819
|
+
const urlResponse = await actor.fetch(url, {
|
|
2946
2820
|
method: "POST",
|
|
2947
2821
|
headers: { "Content-Type": "application/json" },
|
|
2948
2822
|
body: JSON.stringify({ from: "URL object" })
|
|
@@ -2955,7 +2829,7 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2955
2829
|
headers: { "Content-Type": "application/json" },
|
|
2956
2830
|
body: JSON.stringify({ from: "Request object" })
|
|
2957
2831
|
});
|
|
2958
|
-
const requestResponse = await
|
|
2832
|
+
const requestResponse = await actor.fetch(request);
|
|
2959
2833
|
_vitest.expect.call(void 0, requestResponse.ok).toBe(true);
|
|
2960
2834
|
const requestData = await requestResponse.json();
|
|
2961
2835
|
_vitest.expect.call(void 0, requestData).toEqual({ from: "Request object" });
|
|
@@ -2963,7 +2837,7 @@ function runRawHttpTests(driverTestConfig) {
|
|
|
2963
2837
|
method: "GET",
|
|
2964
2838
|
headers: { "X-Original": "request-header" }
|
|
2965
2839
|
});
|
|
2966
|
-
const overrideResponse = await
|
|
2840
|
+
const overrideResponse = await actor.fetch(request2, {
|
|
2967
2841
|
headers: { "X-Override": "init-header" }
|
|
2968
2842
|
});
|
|
2969
2843
|
_vitest.expect.call(void 0, overrideResponse.ok).toBe(true);
|
|
@@ -2980,10 +2854,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
2980
2854
|
_vitest.describe.call(void 0, "raw http request properties", () => {
|
|
2981
2855
|
_vitest.test.call(void 0, "should pass all Request properties correctly to onRequest", async (c) => {
|
|
2982
2856
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2983
|
-
const
|
|
2857
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
2984
2858
|
"test"
|
|
2985
2859
|
]);
|
|
2986
|
-
const response = await
|
|
2860
|
+
const response = await actor.fetch("test/path?foo=bar&baz=qux", {
|
|
2987
2861
|
method: "POST",
|
|
2988
2862
|
headers: {
|
|
2989
2863
|
"Content-Type": "application/json",
|
|
@@ -3009,10 +2883,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3009
2883
|
});
|
|
3010
2884
|
_vitest.test.call(void 0, "should handle GET requests with no body", async (c) => {
|
|
3011
2885
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3012
|
-
const
|
|
2886
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3013
2887
|
"test"
|
|
3014
2888
|
]);
|
|
3015
|
-
const response = await
|
|
2889
|
+
const response = await actor.fetch("test/get", {
|
|
3016
2890
|
method: "GET"
|
|
3017
2891
|
});
|
|
3018
2892
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
@@ -3022,13 +2896,13 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3022
2896
|
});
|
|
3023
2897
|
_vitest.test.call(void 0, "should handle different content types", async (c) => {
|
|
3024
2898
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3025
|
-
const
|
|
2899
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3026
2900
|
"test"
|
|
3027
2901
|
]);
|
|
3028
2902
|
const formData = new URLSearchParams();
|
|
3029
2903
|
formData.append("field1", "value1");
|
|
3030
2904
|
formData.append("field2", "value2");
|
|
3031
|
-
const formResponse = await
|
|
2905
|
+
const formResponse = await actor.fetch("test/form", {
|
|
3032
2906
|
method: "POST",
|
|
3033
2907
|
headers: {
|
|
3034
2908
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -3041,7 +2915,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3041
2915
|
"application/x-www-form-urlencoded"
|
|
3042
2916
|
);
|
|
3043
2917
|
_vitest.expect.call(void 0, formResult.bodyText).toBe("field1=value1&field2=value2");
|
|
3044
|
-
const textResponse = await
|
|
2918
|
+
const textResponse = await actor.fetch("test/text", {
|
|
3045
2919
|
method: "POST",
|
|
3046
2920
|
headers: {
|
|
3047
2921
|
"Content-Type": "text/plain"
|
|
@@ -3055,10 +2929,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3055
2929
|
});
|
|
3056
2930
|
_vitest.test.call(void 0, "should preserve all header casing and values", async (c) => {
|
|
3057
2931
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3058
|
-
const
|
|
2932
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3059
2933
|
"test"
|
|
3060
2934
|
]);
|
|
3061
|
-
const response = await
|
|
2935
|
+
const response = await actor.fetch("test/headers", {
|
|
3062
2936
|
headers: {
|
|
3063
2937
|
Accept: "application/json",
|
|
3064
2938
|
"Accept-Language": "en-US,en;q=0.9",
|
|
@@ -3077,14 +2951,14 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3077
2951
|
});
|
|
3078
2952
|
_vitest.test.call(void 0, "should handle empty and special URL paths", async (c) => {
|
|
3079
2953
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3080
|
-
const
|
|
2954
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3081
2955
|
"test"
|
|
3082
2956
|
]);
|
|
3083
|
-
const rootResponse = await
|
|
2957
|
+
const rootResponse = await actor.fetch("");
|
|
3084
2958
|
_vitest.expect.call(void 0, rootResponse.ok).toBe(true);
|
|
3085
2959
|
const rootData = await rootResponse.json();
|
|
3086
2960
|
_vitest.expect.call(void 0, rootData.pathname).toBe("/");
|
|
3087
|
-
const specialResponse = await
|
|
2961
|
+
const specialResponse = await actor.fetch(
|
|
3088
2962
|
"test/path%20with%20spaces/and%2Fslashes"
|
|
3089
2963
|
);
|
|
3090
2964
|
_vitest.expect.call(void 0, specialResponse.ok).toBe(true);
|
|
@@ -3092,7 +2966,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3092
2966
|
_vitest.expect.call(void 0, specialData.pathname).toMatch(
|
|
3093
2967
|
/path.*with.*spaces.*and.*slashes/
|
|
3094
2968
|
);
|
|
3095
|
-
const fragmentResponse = await
|
|
2969
|
+
const fragmentResponse = await actor.fetch("test/path#fragment");
|
|
3096
2970
|
_vitest.expect.call(void 0, fragmentResponse.ok).toBe(true);
|
|
3097
2971
|
const fragmentData = await fragmentResponse.json();
|
|
3098
2972
|
_vitest.expect.call(void 0, fragmentData.pathname).toBe("/test/path");
|
|
@@ -3100,7 +2974,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3100
2974
|
});
|
|
3101
2975
|
_vitest.test.call(void 0, "should handle request properties for all HTTP methods", async (c) => {
|
|
3102
2976
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3103
|
-
const
|
|
2977
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3104
2978
|
"test"
|
|
3105
2979
|
]);
|
|
3106
2980
|
const methods = [
|
|
@@ -3113,7 +2987,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3113
2987
|
"OPTIONS"
|
|
3114
2988
|
];
|
|
3115
2989
|
for (const method of methods) {
|
|
3116
|
-
const response = await
|
|
2990
|
+
const response = await actor.fetch(
|
|
3117
2991
|
`test/${method.toLowerCase()}`,
|
|
3118
2992
|
{
|
|
3119
2993
|
method,
|
|
@@ -3138,10 +3012,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3138
3012
|
});
|
|
3139
3013
|
_vitest.test.call(void 0, "should handle complex query parameters", async (c) => {
|
|
3140
3014
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3141
|
-
const
|
|
3015
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3142
3016
|
"test"
|
|
3143
3017
|
]);
|
|
3144
|
-
const response = await
|
|
3018
|
+
const response = await actor.fetch(
|
|
3145
3019
|
"test?key=value1&key=value2&array[]=1&array[]=2&nested[prop]=val"
|
|
3146
3020
|
);
|
|
3147
3021
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
@@ -3152,7 +3026,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3152
3026
|
});
|
|
3153
3027
|
_vitest.test.call(void 0, "should handle multipart form data", async (c) => {
|
|
3154
3028
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3155
|
-
const
|
|
3029
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3156
3030
|
"test"
|
|
3157
3031
|
]);
|
|
3158
3032
|
const boundary = "----RivetKitBoundary";
|
|
@@ -3167,7 +3041,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3167
3041
|
"value2",
|
|
3168
3042
|
`------${boundary}--`
|
|
3169
3043
|
].join("\r\n");
|
|
3170
|
-
const response = await
|
|
3044
|
+
const response = await actor.fetch("test/multipart", {
|
|
3171
3045
|
method: "POST",
|
|
3172
3046
|
headers: {
|
|
3173
3047
|
"Content-Type": `multipart/form-data; boundary=----${boundary}`
|
|
@@ -3184,11 +3058,11 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3184
3058
|
});
|
|
3185
3059
|
_vitest.test.call(void 0, "should handle very long URLs", async (c) => {
|
|
3186
3060
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3187
|
-
const
|
|
3061
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3188
3062
|
"test"
|
|
3189
3063
|
]);
|
|
3190
3064
|
const longValue = "x".repeat(1e3);
|
|
3191
|
-
const response = await
|
|
3065
|
+
const response = await actor.fetch(`test/long?param=${longValue}`);
|
|
3192
3066
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
3193
3067
|
const data = await response.json();
|
|
3194
3068
|
_vitest.expect.call(void 0, data.searchParams.param).toBe(longValue);
|
|
@@ -3196,7 +3070,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3196
3070
|
});
|
|
3197
3071
|
_vitest.test.skip("should handle large request bodies", async (c) => {
|
|
3198
3072
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3199
|
-
const
|
|
3073
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3200
3074
|
"test"
|
|
3201
3075
|
]);
|
|
3202
3076
|
const largeArray = new Array(1e4).fill({
|
|
@@ -3204,7 +3078,7 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3204
3078
|
name: "Test",
|
|
3205
3079
|
description: "This is a test object with some data"
|
|
3206
3080
|
});
|
|
3207
|
-
const response = await
|
|
3081
|
+
const response = await actor.fetch("test/large", {
|
|
3208
3082
|
method: "POST",
|
|
3209
3083
|
headers: {
|
|
3210
3084
|
"Content-Type": "application/json"
|
|
@@ -3217,10 +3091,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3217
3091
|
});
|
|
3218
3092
|
_vitest.test.call(void 0, "should handle missing content-type header", async (c) => {
|
|
3219
3093
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3220
|
-
const
|
|
3094
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3221
3095
|
"test"
|
|
3222
3096
|
]);
|
|
3223
|
-
const response = await
|
|
3097
|
+
const response = await actor.fetch("test/no-content-type", {
|
|
3224
3098
|
method: "POST",
|
|
3225
3099
|
body: "plain text without content-type"
|
|
3226
3100
|
});
|
|
@@ -3230,10 +3104,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3230
3104
|
});
|
|
3231
3105
|
_vitest.test.call(void 0, "should handle empty request body", async (c) => {
|
|
3232
3106
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3233
|
-
const
|
|
3107
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3234
3108
|
"test"
|
|
3235
3109
|
]);
|
|
3236
|
-
const response = await
|
|
3110
|
+
const response = await actor.fetch("test/empty", {
|
|
3237
3111
|
method: "POST",
|
|
3238
3112
|
headers: {
|
|
3239
3113
|
"Content-Type": "application/json"
|
|
@@ -3244,11 +3118,11 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3244
3118
|
});
|
|
3245
3119
|
_vitest.test.call(void 0, "should handle custom HTTP methods", async (c) => {
|
|
3246
3120
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3247
|
-
const
|
|
3121
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3248
3122
|
"test"
|
|
3249
3123
|
]);
|
|
3250
3124
|
try {
|
|
3251
|
-
const response = await
|
|
3125
|
+
const response = await actor.fetch("test/custom", {
|
|
3252
3126
|
method: "CUSTOM"
|
|
3253
3127
|
});
|
|
3254
3128
|
if (response.ok) {
|
|
@@ -3260,10 +3134,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3260
3134
|
});
|
|
3261
3135
|
_vitest.test.call(void 0, "should handle cookies in headers", async (c) => {
|
|
3262
3136
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3263
|
-
const
|
|
3137
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3264
3138
|
"test"
|
|
3265
3139
|
]);
|
|
3266
|
-
const response = await
|
|
3140
|
+
const response = await actor.fetch("test/cookies", {
|
|
3267
3141
|
headers: {
|
|
3268
3142
|
Cookie: "session=abc123; user=test; preferences=dark_mode"
|
|
3269
3143
|
}
|
|
@@ -3276,10 +3150,10 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3276
3150
|
});
|
|
3277
3151
|
_vitest.test.call(void 0, "should handle URL encoding properly", async (c) => {
|
|
3278
3152
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3279
|
-
const
|
|
3153
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3280
3154
|
"test"
|
|
3281
3155
|
]);
|
|
3282
|
-
const response = await
|
|
3156
|
+
const response = await actor.fetch(
|
|
3283
3157
|
"test/encoded?special=%20%21%40%23%24%25%5E%26&unicode=%E2%9C%93&email=test%40example.com"
|
|
3284
3158
|
);
|
|
3285
3159
|
_vitest.expect.call(void 0, response.ok).toBe(true);
|
|
@@ -3290,21 +3164,21 @@ function runRawHttpRequestPropertiesTests(driverTestConfig) {
|
|
|
3290
3164
|
});
|
|
3291
3165
|
_vitest.test.call(void 0, "should handle concurrent requests maintaining separate contexts", async (c) => {
|
|
3292
3166
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3293
|
-
const
|
|
3167
|
+
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
3294
3168
|
"test"
|
|
3295
3169
|
]);
|
|
3296
3170
|
const requests = [
|
|
3297
|
-
|
|
3171
|
+
actor.fetch("test/concurrent?id=1", {
|
|
3298
3172
|
method: "POST",
|
|
3299
3173
|
headers: { "Content-Type": "application/json" },
|
|
3300
3174
|
body: JSON.stringify({ request: 1 })
|
|
3301
3175
|
}),
|
|
3302
|
-
|
|
3176
|
+
actor.fetch("test/concurrent?id=2", {
|
|
3303
3177
|
method: "PUT",
|
|
3304
3178
|
headers: { "Content-Type": "application/json" },
|
|
3305
3179
|
body: JSON.stringify({ request: 2 })
|
|
3306
3180
|
}),
|
|
3307
|
-
|
|
3181
|
+
actor.fetch("test/concurrent?id=3", {
|
|
3308
3182
|
method: "DELETE"
|
|
3309
3183
|
})
|
|
3310
3184
|
];
|
|
@@ -3331,8 +3205,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3331
3205
|
_vitest.describe.call(void 0, "raw websocket", () => {
|
|
3332
3206
|
_vitest.test.call(void 0, "should establish raw WebSocket connection", async (c) => {
|
|
3333
3207
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3334
|
-
const
|
|
3335
|
-
const ws = await
|
|
3208
|
+
const actor = client.rawWebSocketActor.getOrCreate(["basic"]);
|
|
3209
|
+
const ws = await actor.websocket();
|
|
3336
3210
|
await new Promise((resolve) => {
|
|
3337
3211
|
if (ws.readyState === WebSocket.OPEN) {
|
|
3338
3212
|
resolve();
|
|
@@ -3362,8 +3236,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3362
3236
|
});
|
|
3363
3237
|
_vitest.test.call(void 0, "should echo messages", async (c) => {
|
|
3364
3238
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3365
|
-
const
|
|
3366
|
-
const ws = await
|
|
3239
|
+
const actor = client.rawWebSocketActor.getOrCreate(["echo"]);
|
|
3240
|
+
const ws = await actor.websocket();
|
|
3367
3241
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
3368
3242
|
await new Promise((resolve, reject) => {
|
|
3369
3243
|
ws.addEventListener("open", () => resolve(), {
|
|
@@ -3393,8 +3267,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3393
3267
|
});
|
|
3394
3268
|
_vitest.test.call(void 0, "should handle ping/pong protocol", async (c) => {
|
|
3395
3269
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3396
|
-
const
|
|
3397
|
-
const ws = await
|
|
3270
|
+
const actor = client.rawWebSocketActor.getOrCreate(["ping"]);
|
|
3271
|
+
const ws = await actor.websocket();
|
|
3398
3272
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
3399
3273
|
await new Promise((resolve, reject) => {
|
|
3400
3274
|
ws.addEventListener("open", () => resolve(), {
|
|
@@ -3475,10 +3349,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3475
3349
|
});
|
|
3476
3350
|
_vitest.test.call(void 0, "should handle binary data", async (c) => {
|
|
3477
3351
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3478
|
-
const
|
|
3352
|
+
const actor = client.rawWebSocketBinaryActor.getOrCreate([
|
|
3479
3353
|
"binary"
|
|
3480
3354
|
]);
|
|
3481
|
-
const ws = await
|
|
3355
|
+
const ws = await actor.websocket();
|
|
3482
3356
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
3483
3357
|
await new Promise((resolve, reject) => {
|
|
3484
3358
|
ws.addEventListener("open", () => resolve(), {
|
|
@@ -3522,8 +3396,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3522
3396
|
});
|
|
3523
3397
|
_vitest.test.call(void 0, "should work with custom paths", async (c) => {
|
|
3524
3398
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3525
|
-
const
|
|
3526
|
-
const ws = await
|
|
3399
|
+
const actor = client.rawWebSocketActor.getOrCreate(["paths"]);
|
|
3400
|
+
const ws = await actor.websocket("custom/path");
|
|
3527
3401
|
await new Promise((resolve, reject) => {
|
|
3528
3402
|
ws.addEventListener("open", () => {
|
|
3529
3403
|
resolve();
|
|
@@ -3545,8 +3419,8 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3545
3419
|
});
|
|
3546
3420
|
_vitest.test.call(void 0, "should handle connection close properly", async (c) => {
|
|
3547
3421
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3548
|
-
const
|
|
3549
|
-
const ws = await
|
|
3422
|
+
const actor = client.rawWebSocketActor.getOrCreate(["close-test"]);
|
|
3423
|
+
const ws = await actor.websocket();
|
|
3550
3424
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
3551
3425
|
await new Promise((resolve, reject) => {
|
|
3552
3426
|
ws.addEventListener("open", () => resolve(), {
|
|
@@ -3555,7 +3429,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3555
3429
|
ws.addEventListener("close", reject);
|
|
3556
3430
|
});
|
|
3557
3431
|
}
|
|
3558
|
-
const initialStats = await
|
|
3432
|
+
const initialStats = await actor.getStats();
|
|
3559
3433
|
_vitest.expect.call(void 0, initialStats.connectionCount).toBe(1);
|
|
3560
3434
|
const closePromise = new Promise((resolve) => {
|
|
3561
3435
|
ws.addEventListener("close", () => resolve(), { once: true });
|
|
@@ -3564,7 +3438,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3564
3438
|
await closePromise;
|
|
3565
3439
|
let finalStats;
|
|
3566
3440
|
for (let i = 0; i < 20; i++) {
|
|
3567
|
-
finalStats = await
|
|
3441
|
+
finalStats = await actor.getStats();
|
|
3568
3442
|
if (finalStats.connectionCount === 0) {
|
|
3569
3443
|
break;
|
|
3570
3444
|
}
|
|
@@ -3574,10 +3448,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3574
3448
|
});
|
|
3575
3449
|
_vitest.test.call(void 0, "should properly handle onWebSocket open and close events", async (c) => {
|
|
3576
3450
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3577
|
-
const
|
|
3451
|
+
const actor = client.rawWebSocketActor.getOrCreate([
|
|
3578
3452
|
"open-close-test"
|
|
3579
3453
|
]);
|
|
3580
|
-
const ws1 = await
|
|
3454
|
+
const ws1 = await actor.websocket();
|
|
3581
3455
|
await new Promise((resolve, reject) => {
|
|
3582
3456
|
ws1.addEventListener("open", () => resolve(), { once: true });
|
|
3583
3457
|
ws1.addEventListener("close", reject);
|
|
@@ -3594,7 +3468,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3594
3468
|
});
|
|
3595
3469
|
_vitest.expect.call(void 0, welcome1.type).toBe("welcome");
|
|
3596
3470
|
_vitest.expect.call(void 0, welcome1.connectionCount).toBe(1);
|
|
3597
|
-
const ws2 = await
|
|
3471
|
+
const ws2 = await actor.websocket();
|
|
3598
3472
|
await new Promise((resolve, reject) => {
|
|
3599
3473
|
ws2.addEventListener("open", () => resolve(), { once: true });
|
|
3600
3474
|
ws2.addEventListener("close", reject);
|
|
@@ -3611,7 +3485,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3611
3485
|
});
|
|
3612
3486
|
_vitest.expect.call(void 0, welcome2.type).toBe("welcome");
|
|
3613
3487
|
_vitest.expect.call(void 0, welcome2.connectionCount).toBe(2);
|
|
3614
|
-
const midStats = await
|
|
3488
|
+
const midStats = await actor.getStats();
|
|
3615
3489
|
_vitest.expect.call(void 0, midStats.connectionCount).toBe(2);
|
|
3616
3490
|
ws1.close();
|
|
3617
3491
|
await new Promise((resolve) => {
|
|
@@ -3619,7 +3493,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3619
3493
|
});
|
|
3620
3494
|
let afterFirstClose;
|
|
3621
3495
|
for (let i = 0; i < 20; i++) {
|
|
3622
|
-
afterFirstClose = await
|
|
3496
|
+
afterFirstClose = await actor.getStats();
|
|
3623
3497
|
if (afterFirstClose.connectionCount === 1) {
|
|
3624
3498
|
break;
|
|
3625
3499
|
}
|
|
@@ -3632,7 +3506,7 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3632
3506
|
});
|
|
3633
3507
|
let finalStats;
|
|
3634
3508
|
for (let i = 0; i < 20; i++) {
|
|
3635
|
-
finalStats = await
|
|
3509
|
+
finalStats = await actor.getStats();
|
|
3636
3510
|
if (finalStats.connectionCount === 0) {
|
|
3637
3511
|
break;
|
|
3638
3512
|
}
|
|
@@ -3642,10 +3516,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3642
3516
|
});
|
|
3643
3517
|
_vitest.test.call(void 0, "should handle query parameters in websocket paths", async (c) => {
|
|
3644
3518
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3645
|
-
const
|
|
3519
|
+
const actor = client.rawWebSocketActor.getOrCreate([
|
|
3646
3520
|
"query-params"
|
|
3647
3521
|
]);
|
|
3648
|
-
const ws = await
|
|
3522
|
+
const ws = await actor.websocket(
|
|
3649
3523
|
"api/v1/stream?token=abc123&user=test"
|
|
3650
3524
|
);
|
|
3651
3525
|
await new Promise((resolve, reject) => {
|
|
@@ -3670,10 +3544,10 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3670
3544
|
});
|
|
3671
3545
|
_vitest.test.call(void 0, "should handle query parameters on base websocket path (no subpath)", async (c) => {
|
|
3672
3546
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3673
|
-
const
|
|
3547
|
+
const actor = client.rawWebSocketActor.getOrCreate([
|
|
3674
3548
|
"base-path-query-params"
|
|
3675
3549
|
]);
|
|
3676
|
-
const ws = await
|
|
3550
|
+
const ws = await actor.websocket("?token=secret&session=123");
|
|
3677
3551
|
await new Promise((resolve, reject) => {
|
|
3678
3552
|
ws.addEventListener("open", () => resolve(), { once: true });
|
|
3679
3553
|
ws.addEventListener("error", reject);
|
|
@@ -3805,6 +3679,7 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
3805
3679
|
runActorConnTests(driverTestConfig);
|
|
3806
3680
|
runActorConnStateTests(driverTestConfig);
|
|
3807
3681
|
runActorConnHibernationTests(driverTestConfig);
|
|
3682
|
+
runConnErrorSerializationTests(driverTestConfig);
|
|
3808
3683
|
runActorDestroyTests(driverTestConfig);
|
|
3809
3684
|
runRequestAccessTests(driverTestConfig);
|
|
3810
3685
|
runActorHandleTests(driverTestConfig);
|
|
@@ -3852,7 +3727,7 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
3852
3727
|
const parsedConfig = registry.parseConfig();
|
|
3853
3728
|
const managerDriver = (_a = driver.manager) == null ? void 0 : _a.call(driver, parsedConfig);
|
|
3854
3729
|
_invariant2.default.call(void 0, managerDriver, "missing manager driver");
|
|
3855
|
-
const { router } =
|
|
3730
|
+
const { router } = _chunkBEMEUFS2cjs.buildManagerRouter.call(void 0,
|
|
3856
3731
|
parsedConfig,
|
|
3857
3732
|
managerDriver,
|
|
3858
3733
|
() => upgradeWebSocket
|
|
@@ -3860,7 +3735,7 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
3860
3735
|
const nodeWebSocket = _nodews.createNodeWebSocket.call(void 0, { app: router });
|
|
3861
3736
|
upgradeWebSocket = nodeWebSocket.upgradeWebSocket;
|
|
3862
3737
|
managerDriver.setGetUpgradeWebSocket(() => upgradeWebSocket);
|
|
3863
|
-
const port = await
|
|
3738
|
+
const port = await _chunkROVVTBUEcjs.getPort.call(void 0, );
|
|
3864
3739
|
const server = _nodeserver.serve.call(void 0, {
|
|
3865
3740
|
fetch: router.fetch,
|
|
3866
3741
|
hostname: "127.0.0.1",
|
|
@@ -3872,7 +3747,7 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
3872
3747
|
);
|
|
3873
3748
|
nodeWebSocket.injectWebSocket(server);
|
|
3874
3749
|
const serverEndpoint = `http://127.0.0.1:${port}`;
|
|
3875
|
-
logger().info({ msg: "test serer listening", port });
|
|
3750
|
+
_chunkR33VIC3Wcjs.logger.call(void 0, ).info({ msg: "test serer listening", port });
|
|
3876
3751
|
const cleanup = async () => {
|
|
3877
3752
|
await new Promise(
|
|
3878
3753
|
(resolve) => server.close(() => resolve(void 0))
|