rivetkit 2.0.5 → 2.0.7-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schemas/actor-persist/v1.ts +0 -6
- package/dist/tsup/actor-router-consts-B3Lu87yJ.d.cts +28 -0
- package/dist/tsup/actor-router-consts-B3Lu87yJ.d.ts +28 -0
- package/dist/tsup/{chunk-5YTI25C3.cjs → chunk-3MBP4WNC.cjs} +7 -7
- package/dist/tsup/{chunk-5YTI25C3.cjs.map → chunk-3MBP4WNC.cjs.map} +1 -1
- package/dist/tsup/chunk-3Y45CIF4.cjs +3726 -0
- package/dist/tsup/chunk-3Y45CIF4.cjs.map +1 -0
- package/dist/tsup/chunk-4GP7BZSR.js +102 -0
- package/dist/tsup/chunk-4GP7BZSR.js.map +1 -0
- package/dist/tsup/chunk-5ZOHIKWG.cjs +4071 -0
- package/dist/tsup/chunk-5ZOHIKWG.cjs.map +1 -0
- package/dist/tsup/{chunk-WADSS5X4.cjs → chunk-6EUWRXLT.cjs} +21 -7
- package/dist/tsup/chunk-6EUWRXLT.cjs.map +1 -0
- package/dist/tsup/{chunk-D7NWUCRK.cjs → chunk-6OVKCDSH.cjs} +6 -6
- package/dist/tsup/{chunk-D7NWUCRK.cjs.map → chunk-6OVKCDSH.cjs.map} +1 -1
- package/dist/tsup/{chunk-I5VTWPHW.js → chunk-7N56ZUC7.js} +3 -3
- package/dist/tsup/{chunk-LZIBTLEY.cjs → chunk-B3TLRM4Q.cjs} +13 -25
- package/dist/tsup/chunk-B3TLRM4Q.cjs.map +1 -0
- package/dist/tsup/chunk-BW5DPM6Z.js +4071 -0
- package/dist/tsup/chunk-BW5DPM6Z.js.map +1 -0
- package/dist/tsup/chunk-DFS77KAA.cjs +1046 -0
- package/dist/tsup/chunk-DFS77KAA.cjs.map +1 -0
- package/dist/tsup/{chunk-PG3K2LI7.js → chunk-E4UVJKSV.js} +2 -2
- package/dist/tsup/chunk-G4ABMAQY.cjs +102 -0
- package/dist/tsup/chunk-G4ABMAQY.cjs.map +1 -0
- package/dist/tsup/{chunk-CKA54YQN.js → chunk-GZVBFXBI.js} +3 -15
- package/dist/tsup/chunk-GZVBFXBI.js.map +1 -0
- package/dist/tsup/chunk-HPT3I7UU.js +3726 -0
- package/dist/tsup/chunk-HPT3I7UU.js.map +1 -0
- package/dist/tsup/chunk-JD54PXWP.js +1046 -0
- package/dist/tsup/chunk-JD54PXWP.js.map +1 -0
- package/dist/tsup/{chunk-PHSQJ6QI.cjs → chunk-K4ENQCC4.cjs} +3 -3
- package/dist/tsup/{chunk-PHSQJ6QI.cjs.map → chunk-K4ENQCC4.cjs.map} +1 -1
- package/dist/tsup/{chunk-WNGOBAA7.js → chunk-PUSQNDJG.js} +2 -2
- package/dist/tsup/{chunk-CFFKMUYH.js → chunk-RVP5RUSC.js} +20 -6
- package/dist/tsup/chunk-RVP5RUSC.js.map +1 -0
- package/dist/tsup/chunk-SAZCNSVY.cjs +259 -0
- package/dist/tsup/chunk-SAZCNSVY.cjs.map +1 -0
- package/dist/tsup/{chunk-YW6Y6VNE.js → chunk-SBKRVQS2.js} +9 -5
- package/dist/tsup/chunk-SBKRVQS2.js.map +1 -0
- package/dist/tsup/{chunk-FGFT4FVX.cjs → chunk-TZGUSEIJ.cjs} +14 -10
- package/dist/tsup/chunk-TZGUSEIJ.cjs.map +1 -0
- package/dist/tsup/chunk-YQ4XQYPM.js +259 -0
- package/dist/tsup/chunk-YQ4XQYPM.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +7 -8
- package/dist/tsup/client/mod.d.ts +7 -8
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +3 -3
- package/dist/tsup/common/log.js +2 -2
- package/dist/tsup/common/websocket.cjs +4 -4
- package/dist/tsup/common/websocket.js +3 -3
- package/dist/tsup/{connection-BvE-Oq7t.d.ts → conn-DCSQgIlw.d.ts} +1605 -1353
- package/dist/tsup/{connection-DTzmWwU5.d.cts → conn-DdzHTm2E.d.cts} +1605 -1353
- package/dist/tsup/driver-helpers/mod.cjs +31 -5
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +7 -8
- package/dist/tsup/driver-helpers/mod.d.ts +7 -8
- package/dist/tsup/driver-helpers/mod.js +33 -7
- package/dist/tsup/driver-test-suite/mod.cjs +319 -216
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +7 -7
- package/dist/tsup/driver-test-suite/mod.d.ts +7 -7
- package/dist/tsup/driver-test-suite/mod.js +588 -485
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +17 -5
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +34 -7
- package/dist/tsup/inspector/mod.d.ts +34 -7
- package/dist/tsup/inspector/mod.js +20 -8
- package/dist/tsup/mod.cjs +10 -17
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +56 -9
- package/dist/tsup/mod.d.ts +56 -9
- package/dist/tsup/mod.js +17 -24
- package/dist/tsup/test/mod.cjs +11 -9
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +6 -7
- package/dist/tsup/test/mod.d.ts +6 -7
- package/dist/tsup/test/mod.js +10 -8
- package/dist/tsup/utils.cjs +4 -2
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +11 -1
- package/dist/tsup/utils.d.ts +11 -1
- package/dist/tsup/utils.js +3 -1
- package/package.json +8 -4
- package/src/actor/action.ts +1 -1
- package/src/actor/config.ts +1 -1
- package/src/actor/conn-drivers.ts +205 -0
- package/src/actor/conn-socket.ts +6 -0
- package/src/actor/{connection.ts → conn.ts} +78 -84
- package/src/actor/context.ts +1 -1
- package/src/actor/driver.ts +4 -43
- package/src/actor/instance.ts +162 -86
- package/src/actor/mod.ts +6 -14
- package/src/actor/persisted.ts +2 -5
- package/src/actor/protocol/old.ts +1 -1
- package/src/actor/router-endpoints.ts +147 -138
- package/src/actor/router.ts +89 -52
- package/src/actor/utils.ts +5 -1
- package/src/client/actor-conn.ts +163 -31
- package/src/client/actor-handle.ts +0 -1
- package/src/client/client.ts +2 -2
- package/src/client/config.ts +7 -0
- package/src/client/raw-utils.ts +1 -1
- package/src/client/utils.ts +1 -1
- package/src/common/actor-router-consts.ts +59 -0
- package/src/common/router.ts +2 -1
- package/src/common/versioned-data.ts +5 -5
- package/src/driver-helpers/mod.ts +15 -2
- package/src/driver-test-suite/mod.ts +11 -2
- package/src/driver-test-suite/test-inline-client-driver.ts +40 -22
- package/src/driver-test-suite/tests/actor-conn-state.ts +66 -22
- package/src/driver-test-suite/tests/actor-conn.ts +65 -126
- package/src/driver-test-suite/tests/actor-reconnect.ts +160 -0
- package/src/driver-test-suite/tests/actor-sleep.ts +0 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +0 -35
- package/src/driver-test-suite/utils.ts +8 -3
- package/src/drivers/default.ts +8 -7
- package/src/drivers/engine/actor-driver.ts +67 -44
- package/src/drivers/engine/config.ts +4 -0
- package/src/drivers/file-system/actor.ts +0 -6
- package/src/drivers/file-system/global-state.ts +3 -14
- package/src/drivers/file-system/manager.ts +12 -8
- package/src/inspector/actor.ts +4 -3
- package/src/inspector/config.ts +10 -1
- package/src/inspector/mod.ts +1 -0
- package/src/inspector/utils.ts +23 -4
- package/src/manager/driver.ts +12 -2
- package/src/manager/gateway.ts +407 -0
- package/src/manager/protocol/query.ts +1 -1
- package/src/manager/router.ts +269 -468
- package/src/manager-api/actors.ts +61 -0
- package/src/manager-api/common.ts +4 -0
- package/src/mod.ts +1 -1
- package/src/registry/mod.ts +126 -12
- package/src/registry/serve.ts +8 -3
- package/src/remote-manager-driver/actor-http-client.ts +30 -19
- package/src/remote-manager-driver/actor-websocket-client.ts +45 -18
- package/src/remote-manager-driver/api-endpoints.ts +19 -21
- package/src/remote-manager-driver/api-utils.ts +10 -1
- package/src/remote-manager-driver/mod.ts +53 -53
- package/src/remote-manager-driver/ws-proxy.ts +2 -9
- package/src/test/mod.ts +6 -2
- package/src/utils.ts +21 -2
- package/dist/tsup/chunk-2MD57QF4.js +0 -1794
- package/dist/tsup/chunk-2MD57QF4.js.map +0 -1
- package/dist/tsup/chunk-B2QGJGZQ.js +0 -338
- package/dist/tsup/chunk-B2QGJGZQ.js.map +0 -1
- package/dist/tsup/chunk-CFFKMUYH.js.map +0 -1
- package/dist/tsup/chunk-CKA54YQN.js.map +0 -1
- package/dist/tsup/chunk-FGFT4FVX.cjs.map +0 -1
- package/dist/tsup/chunk-IRMBWX36.cjs +0 -1794
- package/dist/tsup/chunk-IRMBWX36.cjs.map +0 -1
- package/dist/tsup/chunk-L7QRXNWP.js +0 -6562
- package/dist/tsup/chunk-L7QRXNWP.js.map +0 -1
- package/dist/tsup/chunk-LZIBTLEY.cjs.map +0 -1
- package/dist/tsup/chunk-MRZS2J4X.cjs +0 -6562
- package/dist/tsup/chunk-MRZS2J4X.cjs.map +0 -1
- package/dist/tsup/chunk-RM2SVURR.cjs +0 -338
- package/dist/tsup/chunk-RM2SVURR.cjs.map +0 -1
- package/dist/tsup/chunk-WADSS5X4.cjs.map +0 -1
- package/dist/tsup/chunk-YW6Y6VNE.js.map +0 -1
- package/dist/tsup/common-CXCe7s6i.d.cts +0 -218
- package/dist/tsup/common-CXCe7s6i.d.ts +0 -218
- package/dist/tsup/router-endpoints-CctffZNL.d.cts +0 -65
- package/dist/tsup/router-endpoints-DFm1BglJ.d.ts +0 -65
- package/src/actor/generic-conn-driver.ts +0 -246
- package/src/common/fake-event-source.ts +0 -267
- package/src/manager-api/routes/actors-create.ts +0 -16
- package/src/manager-api/routes/actors-delete.ts +0 -4
- package/src/manager-api/routes/actors-get-by-id.ts +0 -7
- package/src/manager-api/routes/actors-get-or-create-by-id.ts +0 -29
- package/src/manager-api/routes/actors-get.ts +0 -7
- package/src/manager-api/routes/common.ts +0 -18
- /package/dist/tsup/{chunk-I5VTWPHW.js.map → chunk-7N56ZUC7.js.map} +0 -0
- /package/dist/tsup/{chunk-PG3K2LI7.js.map → chunk-E4UVJKSV.js.map} +0 -0
- /package/dist/tsup/{chunk-WNGOBAA7.js.map → chunk-PUSQNDJG.js.map} +0 -0
|
@@ -1,34 +1,46 @@
|
|
|
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
|
|
3
|
+
var _chunkTZGUSEIJcjs = require('../chunk-TZGUSEIJ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var _chunkD7NWUCRKcjs = require('../chunk-D7NWUCRK.cjs');
|
|
7
6
|
|
|
7
|
+
var _chunk3Y45CIF4cjs = require('../chunk-3Y45CIF4.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkG4ABMAQYcjs = require('../chunk-G4ABMAQY.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
var _chunk6OVKCDSHcjs = require('../chunk-6OVKCDSH.cjs');
|
|
15
16
|
|
|
16
|
-
var _chunkLZIBTLEYcjs = require('../chunk-LZIBTLEY.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk5ZOHIKWGcjs = require('../chunk-5ZOHIKWG.cjs');
|
|
20
|
+
require('../chunk-B3TLRM4Q.cjs');
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
var
|
|
23
|
+
var _chunkK4ENQCC4cjs = require('../chunk-K4ENQCC4.cjs');
|
|
23
24
|
|
|
24
25
|
|
|
26
|
+
var _chunkDFS77KAAcjs = require('../chunk-DFS77KAA.cjs');
|
|
25
27
|
|
|
26
28
|
|
|
27
|
-
var _chunkIRMBWX36cjs = require('../chunk-IRMBWX36.cjs');
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var _chunkSAZCNSVYcjs = require('../chunk-SAZCNSVY.cjs');
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var _chunk3MBP4WNCcjs = require('../chunk-3MBP4WNC.cjs');
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var _chunk6EUWRXLTcjs = require('../chunk-6EUWRXLT.cjs');
|
|
32
44
|
|
|
33
45
|
|
|
34
46
|
|
|
@@ -43,7 +55,7 @@ var _vitest = require('vitest');
|
|
|
43
55
|
|
|
44
56
|
// src/driver-test-suite/log.ts
|
|
45
57
|
function logger() {
|
|
46
|
-
return
|
|
58
|
+
return _chunk3MBP4WNCcjs.getLogger.call(void 0, "test-suite");
|
|
47
59
|
}
|
|
48
60
|
|
|
49
61
|
// src/driver-test-suite/tests/action-features.ts
|
|
@@ -94,13 +106,14 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
|
|
|
94
106
|
const url = `${endpoint}/.test/inline-driver/send-request/${pathWithQuery}`;
|
|
95
107
|
logger().debug({ msg: "rewriting http url", from: oldUrl, to: url });
|
|
96
108
|
const headers = new Headers(actorRequest.headers);
|
|
97
|
-
headers.set(
|
|
109
|
+
headers.set(_chunkSAZCNSVYcjs.HEADER_ACTOR_ID, actorId);
|
|
98
110
|
const response = await fetch(
|
|
99
111
|
new Request(url, {
|
|
100
112
|
method: actorRequest.method,
|
|
101
113
|
headers,
|
|
102
114
|
body: actorRequest.body,
|
|
103
|
-
signal: actorRequest.signal
|
|
115
|
+
signal: actorRequest.signal,
|
|
116
|
+
duplex: "half"
|
|
104
117
|
})
|
|
105
118
|
);
|
|
106
119
|
if (!response.ok && ((_a = response.headers.get("content-type")) == null ? void 0 : _a.includes("application/json"))) {
|
|
@@ -109,7 +122,7 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
|
|
|
109
122
|
const errorData = await clonedResponse.json();
|
|
110
123
|
if (errorData.error) {
|
|
111
124
|
if (typeof errorData.error === "object") {
|
|
112
|
-
throw new (0,
|
|
125
|
+
throw new (0, _chunk5ZOHIKWGcjs.ActorError)(
|
|
113
126
|
errorData.error.code,
|
|
114
127
|
errorData.error.message,
|
|
115
128
|
errorData.error.metadata
|
|
@@ -117,7 +130,7 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
|
|
|
117
130
|
}
|
|
118
131
|
}
|
|
119
132
|
} catch (e) {
|
|
120
|
-
if (!(e instanceof
|
|
133
|
+
if (!(e instanceof _chunk5ZOHIKWGcjs.ActorError)) {
|
|
121
134
|
return response;
|
|
122
135
|
}
|
|
123
136
|
throw e;
|
|
@@ -125,38 +138,46 @@ function createTestInlineClientDriver(endpoint, encoding, transport) {
|
|
|
125
138
|
}
|
|
126
139
|
return response;
|
|
127
140
|
},
|
|
128
|
-
async openWebSocket(path, actorId, encoding2, params) {
|
|
129
|
-
const WebSocket2 = await
|
|
141
|
+
async openWebSocket(path, actorId, encoding2, params, connId, connToken) {
|
|
142
|
+
const WebSocket2 = await _chunkK4ENQCC4cjs.importWebSocket.call(void 0, );
|
|
130
143
|
const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
131
|
-
logger().debug({
|
|
132
|
-
msg: "creating websocket connection via test inline driver"
|
|
133
|
-
});
|
|
134
144
|
const wsUrl = new URL(
|
|
135
145
|
`${endpoint}/.test/inline-driver/connect-websocket/ws`
|
|
136
146
|
);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
wsUrl.searchParams.set("encodingKind", encoding2);
|
|
147
|
+
logger().debug({
|
|
148
|
+
msg: "creating websocket connection via test inline driver",
|
|
149
|
+
url: wsUrl.toString()
|
|
150
|
+
});
|
|
142
151
|
const wsProtocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
143
|
-
const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}
|
|
152
|
+
const finalWsUrl = `${wsProtocol}//${wsUrl.host}${wsUrl.pathname}`;
|
|
144
153
|
logger().debug({ msg: "connecting to websocket", url: finalWsUrl });
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
const protocols = [];
|
|
155
|
+
protocols.push(`${_chunkSAZCNSVYcjs.WS_PROTOCOL_TARGET}actor`);
|
|
156
|
+
protocols.push(`${_chunkSAZCNSVYcjs.WS_PROTOCOL_ACTOR}${actorId}`);
|
|
157
|
+
protocols.push(`${_chunkSAZCNSVYcjs.WS_PROTOCOL_ENCODING}${encoding2}`);
|
|
158
|
+
protocols.push(`${_chunkSAZCNSVYcjs.WS_PROTOCOL_TRANSPORT}${transport}`);
|
|
159
|
+
protocols.push(
|
|
160
|
+
`${_chunkSAZCNSVYcjs.WS_PROTOCOL_PATH}${encodeURIComponent(normalizedPath)}`
|
|
161
|
+
);
|
|
162
|
+
if (params !== void 0) {
|
|
163
|
+
protocols.push(
|
|
164
|
+
`${_chunkSAZCNSVYcjs.WS_PROTOCOL_CONN_PARAMS}${encodeURIComponent(JSON.stringify(params))}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const ws = new WebSocket2(finalWsUrl, protocols);
|
|
149
168
|
return ws;
|
|
150
169
|
},
|
|
151
170
|
async proxyRequest(c, actorRequest, actorId) {
|
|
152
171
|
return await this.sendRequest(actorId, actorRequest);
|
|
153
172
|
},
|
|
154
|
-
proxyWebSocket(_c, _path, _actorId, _encoding, _params
|
|
173
|
+
proxyWebSocket(_c, _path, _actorId, _encoding, _params) {
|
|
155
174
|
throw "UNIMPLEMENTED";
|
|
156
175
|
},
|
|
157
176
|
displayInformation() {
|
|
158
177
|
return { name: "Test Inline", properties: {} };
|
|
159
|
-
}
|
|
178
|
+
},
|
|
179
|
+
// TODO:
|
|
180
|
+
getOrCreateInspectorAccessToken: () => ""
|
|
160
181
|
// action: async <Args extends Array<unknown> = unknown[], Response = unknown>(
|
|
161
182
|
// _c: HonoContext | undefined,
|
|
162
183
|
// actorQuery: ActorQuery,
|
|
@@ -492,7 +513,8 @@ async function makeInlineRequest(endpoint, encoding, transport, method, args) {
|
|
|
492
513
|
transport,
|
|
493
514
|
method,
|
|
494
515
|
args
|
|
495
|
-
})
|
|
516
|
+
}),
|
|
517
|
+
duplex: "half"
|
|
496
518
|
});
|
|
497
519
|
if (!response.ok) {
|
|
498
520
|
throw new Error(`Failed to call inline ${method}: ${response.statusText}`);
|
|
@@ -504,14 +526,14 @@ async function makeInlineRequest(endpoint, encoding, transport, method, args) {
|
|
|
504
526
|
if ("ok" in callResponse) {
|
|
505
527
|
return callResponse.ok;
|
|
506
528
|
} else if ("err" in callResponse) {
|
|
507
|
-
throw new (0,
|
|
529
|
+
throw new (0, _chunk5ZOHIKWGcjs.ActorError)(
|
|
508
530
|
callResponse.err.group,
|
|
509
531
|
callResponse.err.code,
|
|
510
532
|
callResponse.err.message,
|
|
511
533
|
callResponse.err.metadata
|
|
512
534
|
);
|
|
513
535
|
} else {
|
|
514
|
-
|
|
536
|
+
_chunkSAZCNSVYcjs.assertUnreachable.call(void 0, callResponse);
|
|
515
537
|
}
|
|
516
538
|
}
|
|
517
539
|
|
|
@@ -526,21 +548,25 @@ async function setupDriverTest(c, driverTestConfig) {
|
|
|
526
548
|
c.onTestFinished(cleanup);
|
|
527
549
|
let client;
|
|
528
550
|
if (driverTestConfig.clientType === "http") {
|
|
529
|
-
client =
|
|
551
|
+
client = _chunk6OVKCDSHcjs.createClient.call(void 0, {
|
|
530
552
|
endpoint,
|
|
531
553
|
namespace,
|
|
532
554
|
runnerName,
|
|
533
555
|
transport: driverTestConfig.transport
|
|
534
556
|
});
|
|
535
557
|
} else if (driverTestConfig.clientType === "inline") {
|
|
558
|
+
const transport = _nullishCoalesce(driverTestConfig.transport, () => ( "websocket"));
|
|
536
559
|
const managerDriver = createTestInlineClientDriver(
|
|
537
560
|
endpoint,
|
|
538
561
|
"bare",
|
|
539
|
-
|
|
562
|
+
transport
|
|
540
563
|
);
|
|
541
|
-
|
|
564
|
+
const runConfig = _chunkDFS77KAAcjs.RunConfigSchema.parse({
|
|
565
|
+
transport
|
|
566
|
+
});
|
|
567
|
+
client = _chunk5ZOHIKWGcjs.createClientWithDriver.call(void 0, managerDriver, runConfig);
|
|
542
568
|
} else {
|
|
543
|
-
|
|
569
|
+
_chunkSAZCNSVYcjs.assertUnreachable.call(void 0, driverTestConfig.clientType);
|
|
544
570
|
}
|
|
545
571
|
if (!driverTestConfig.HACK_skipCleanupNet) {
|
|
546
572
|
c.onTestFinished(async () => await client.dispose());
|
|
@@ -688,17 +714,19 @@ function runActorConnTests(driverTestConfig) {
|
|
|
688
714
|
const handle = client.counter.getOrCreate(["test-mixed-rpc-ws"]);
|
|
689
715
|
const connection = handle.connect();
|
|
690
716
|
const receivedEvents = [];
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
717
|
+
connection.on("newCount", (count) => {
|
|
718
|
+
receivedEvents.push(count);
|
|
719
|
+
});
|
|
720
|
+
await _vitest.vi.waitFor(async () => {
|
|
721
|
+
await connection.setCount(1);
|
|
722
|
+
_vitest.expect.call(void 0, receivedEvents).includes(1);
|
|
723
|
+
});
|
|
724
|
+
await handle.setCount(2);
|
|
725
|
+
await handle.setCount(3);
|
|
726
|
+
await _vitest.vi.waitFor(() => {
|
|
727
|
+
_vitest.expect.call(void 0, receivedEvents).includes(2);
|
|
728
|
+
_vitest.expect.call(void 0, receivedEvents).includes(3);
|
|
697
729
|
});
|
|
698
|
-
await connection.increment(1);
|
|
699
|
-
await handle.increment(5);
|
|
700
|
-
await handle.increment(3);
|
|
701
|
-
await receivedEventsPromise;
|
|
702
730
|
await connection.dispose();
|
|
703
731
|
});
|
|
704
732
|
_vitest.test.call(void 0, "should receive events via broadcast", async (c) => {
|
|
@@ -709,10 +737,15 @@ function runActorConnTests(driverTestConfig) {
|
|
|
709
737
|
connection.on("newCount", (count) => {
|
|
710
738
|
receivedEvents.push(count);
|
|
711
739
|
});
|
|
712
|
-
await
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
740
|
+
await _vitest.vi.waitFor(
|
|
741
|
+
async () => {
|
|
742
|
+
await connection.setCount(5);
|
|
743
|
+
await connection.setCount(8);
|
|
744
|
+
_vitest.expect.call(void 0, receivedEvents).toContain(5);
|
|
745
|
+
_vitest.expect.call(void 0, receivedEvents).toContain(8);
|
|
746
|
+
},
|
|
747
|
+
{ timeout: 1e4 }
|
|
748
|
+
);
|
|
716
749
|
await connection.dispose();
|
|
717
750
|
});
|
|
718
751
|
_vitest.test.call(void 0, "should handle one-time events with once()", async (c) => {
|
|
@@ -725,8 +758,10 @@ function runActorConnTests(driverTestConfig) {
|
|
|
725
758
|
});
|
|
726
759
|
await connection.increment(5);
|
|
727
760
|
await connection.increment(3);
|
|
728
|
-
_vitest.
|
|
729
|
-
|
|
761
|
+
await _vitest.vi.waitFor(() => {
|
|
762
|
+
_vitest.expect.call(void 0, receivedEvents).toEqual([5]);
|
|
763
|
+
_vitest.expect.call(void 0, receivedEvents).not.toContain(8);
|
|
764
|
+
});
|
|
730
765
|
await connection.dispose();
|
|
731
766
|
});
|
|
732
767
|
_vitest.test.call(void 0, "should unsubscribe from events", async (c) => {
|
|
@@ -737,10 +772,12 @@ function runActorConnTests(driverTestConfig) {
|
|
|
737
772
|
const unsubscribe = connection.on("newCount", (count) => {
|
|
738
773
|
receivedEvents.push(count);
|
|
739
774
|
});
|
|
740
|
-
await
|
|
775
|
+
await _vitest.vi.waitFor(async () => {
|
|
776
|
+
await connection.setCount(5);
|
|
777
|
+
_vitest.expect.call(void 0, receivedEvents).toEqual([5]);
|
|
778
|
+
});
|
|
741
779
|
unsubscribe();
|
|
742
|
-
await connection.
|
|
743
|
-
_vitest.expect.call(void 0, receivedEvents).toEqual([5]);
|
|
780
|
+
await connection.setCount(8);
|
|
744
781
|
_vitest.expect.call(void 0, receivedEvents).not.toContain(8);
|
|
745
782
|
await connection.dispose();
|
|
746
783
|
});
|
|
@@ -766,7 +803,9 @@ function runActorConnTests(driverTestConfig) {
|
|
|
766
803
|
});
|
|
767
804
|
});
|
|
768
805
|
_vitest.describe.call(void 0, "Lifecycle Hooks", () => {
|
|
769
|
-
_vitest.test.
|
|
806
|
+
_vitest.test.skipIf(
|
|
807
|
+
driverTestConfig.transport === "sse" && driverTestConfig.clientType === "inline"
|
|
808
|
+
)("should trigger lifecycle hooks", async (c) => {
|
|
770
809
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
771
810
|
const connHandle = client.counterWithLifecycle.getOrCreate(
|
|
772
811
|
["test-lifecycle"],
|
|
@@ -778,81 +817,30 @@ function runActorConnTests(driverTestConfig) {
|
|
|
778
817
|
const events = await connection.getEvents();
|
|
779
818
|
_vitest.expect.call(void 0, events).toEqual(["onStart", "onBeforeConnect", "onConnect"]);
|
|
780
819
|
await connection.dispose();
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
const connA = handle.connect();
|
|
806
|
-
const connB = handle.connect();
|
|
807
|
-
const connAId = await connA.getConnectionId();
|
|
808
|
-
const connBId = await connB.getConnectionId();
|
|
809
|
-
await connA.increment(5);
|
|
810
|
-
await connB.increment(5);
|
|
811
|
-
const counter = await handle.getCounter();
|
|
812
|
-
_vitest.expect.call(void 0, counter).toBe(10);
|
|
813
|
-
const connectionsStatusBeforeKill = await handle.getWsConnectionsLiveness();
|
|
814
|
-
_vitest.expect.call(void 0, connectionsStatusBeforeKill).toHaveLength(2);
|
|
815
|
-
_vitest.expect.call(void 0, connectionsStatusBeforeKill).toContainEqual(
|
|
816
|
-
_vitest.expect.objectContaining({
|
|
817
|
-
id: connAId,
|
|
818
|
-
status: "connected",
|
|
819
|
-
lastSeen: FAKE_TIME.getTime()
|
|
820
|
-
})
|
|
821
|
-
);
|
|
822
|
-
_vitest.expect.call(void 0, connectionsStatusBeforeKill).toContainEqual(
|
|
823
|
-
_vitest.expect.objectContaining({
|
|
824
|
-
id: connBId,
|
|
825
|
-
status: "connected",
|
|
826
|
-
lastSeen: FAKE_TIME.getTime()
|
|
827
|
-
})
|
|
828
|
-
);
|
|
829
|
-
await handle.kill(connAId);
|
|
830
|
-
const connectionsStatusAfterKill = await handle.getWsConnectionsLiveness();
|
|
831
|
-
_vitest.expect.call(void 0, connectionsStatusAfterKill).toEqual(
|
|
832
|
-
_vitest.expect.arrayContaining([
|
|
833
|
-
_vitest.expect.objectContaining({
|
|
834
|
-
id: connAId,
|
|
835
|
-
status: "reconnecting",
|
|
836
|
-
lastSeen: FAKE_TIME.getTime()
|
|
837
|
-
}),
|
|
838
|
-
_vitest.expect.objectContaining({
|
|
839
|
-
id: connBId,
|
|
840
|
-
status: "connected",
|
|
841
|
-
lastSeen: FAKE_TIME.getTime()
|
|
842
|
-
})
|
|
843
|
-
])
|
|
844
|
-
);
|
|
845
|
-
await waitFor(driverTestConfig, 5e3);
|
|
846
|
-
const connectionsStatusAfterCleanup = await handle.getWsConnectionsLiveness();
|
|
847
|
-
_vitest.expect.call(void 0, connectionsStatusAfterCleanup).not.toContainEqual(
|
|
848
|
-
_vitest.expect.objectContaining({
|
|
849
|
-
id: connAId
|
|
850
|
-
})
|
|
851
|
-
);
|
|
852
|
-
_vitest.expect.call(void 0, connectionsStatusAfterCleanup).toContainEqual(
|
|
853
|
-
_vitest.expect.objectContaining({
|
|
854
|
-
id: connBId
|
|
855
|
-
})
|
|
820
|
+
await _vitest.vi.waitFor(
|
|
821
|
+
async () => {
|
|
822
|
+
const handle = client.counterWithLifecycle.getOrCreate([
|
|
823
|
+
"test-lifecycle"
|
|
824
|
+
]);
|
|
825
|
+
const finalEvents = await handle.getEvents();
|
|
826
|
+
_vitest.expect.call(void 0, finalEvents).toBeOneOf([
|
|
827
|
+
// Still active
|
|
828
|
+
["onStart", "onBeforeConnect", "onConnect", "onDisconnect"],
|
|
829
|
+
// Went to sleep and woke back up
|
|
830
|
+
[
|
|
831
|
+
"onStart",
|
|
832
|
+
"onBeforeConnect",
|
|
833
|
+
"onConnect",
|
|
834
|
+
"onDisconnect",
|
|
835
|
+
"onStart"
|
|
836
|
+
]
|
|
837
|
+
]);
|
|
838
|
+
},
|
|
839
|
+
// NOTE: High timeout required for Cloudflare Workers
|
|
840
|
+
{
|
|
841
|
+
timeout: 1e4,
|
|
842
|
+
interval: 100
|
|
843
|
+
}
|
|
856
844
|
);
|
|
857
845
|
});
|
|
858
846
|
});
|
|
@@ -940,21 +928,57 @@ function runActorConnStateTests(driverTestConfig) {
|
|
|
940
928
|
});
|
|
941
929
|
});
|
|
942
930
|
_vitest.describe.call(void 0, "Connection Lifecycle", () => {
|
|
943
|
-
_vitest.test.
|
|
931
|
+
_vitest.test.skipIf(
|
|
932
|
+
driverTestConfig.transport === "sse" && driverTestConfig.clientType === "inline"
|
|
933
|
+
)("should track connection and disconnection events", async (c) => {
|
|
944
934
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
945
|
-
const
|
|
946
|
-
|
|
935
|
+
const debugHandle = client.connStateActor.getOrCreate(void 0, {
|
|
936
|
+
params: { noCount: true }
|
|
937
|
+
});
|
|
938
|
+
const conn = client.connStateActor.getOrCreate().connect();
|
|
947
939
|
const connState = await conn.getConnectionState();
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
940
|
+
await _vitest.vi.waitFor(async () => {
|
|
941
|
+
const connectionIds = await debugHandle.getConnectionIds();
|
|
942
|
+
_vitest.expect.call(void 0, connectionIds).toContain(connState.id);
|
|
943
|
+
});
|
|
944
|
+
await _vitest.vi.waitFor(async () => {
|
|
945
|
+
const disconnects = await debugHandle.getDisconnectionCount();
|
|
946
|
+
_vitest.expect.call(void 0, disconnects).toBe(0);
|
|
947
|
+
});
|
|
951
948
|
await conn.dispose();
|
|
952
|
-
|
|
949
|
+
await _vitest.vi.waitFor(
|
|
950
|
+
async () => {
|
|
951
|
+
console.log("disconnects before");
|
|
952
|
+
const disconnects = await debugHandle.getDisconnectionCount();
|
|
953
|
+
console.log("disconnects", disconnects);
|
|
954
|
+
_vitest.expect.call(void 0, disconnects).toBe(1);
|
|
955
|
+
},
|
|
956
|
+
// SSE takes a long time to disconnect on CF Workers
|
|
957
|
+
{
|
|
958
|
+
timeout: 1e4,
|
|
959
|
+
interval: 100
|
|
960
|
+
}
|
|
961
|
+
);
|
|
962
|
+
const newConn = client.connStateActor.getOrCreate().connect();
|
|
953
963
|
await _vitest.vi.waitFor(async () => {
|
|
954
|
-
const
|
|
955
|
-
|
|
964
|
+
const connectionIds = await debugHandle.getConnectionIds();
|
|
965
|
+
console.log("conn ids", connectionIds);
|
|
966
|
+
_vitest.expect.call(void 0, connectionIds.length).toBe(1);
|
|
956
967
|
});
|
|
957
968
|
await newConn.dispose();
|
|
969
|
+
await _vitest.vi.waitFor(
|
|
970
|
+
async () => {
|
|
971
|
+
console.log("A");
|
|
972
|
+
const disconnects = await debugHandle.getDisconnectionCount();
|
|
973
|
+
console.log(`B ${disconnects}`);
|
|
974
|
+
_vitest.expect.call(void 0, disconnects).toBe(2);
|
|
975
|
+
},
|
|
976
|
+
// SSE takes a long time to disconnect on CF Workers
|
|
977
|
+
{
|
|
978
|
+
timeout: 1e4,
|
|
979
|
+
interval: 100
|
|
980
|
+
}
|
|
981
|
+
);
|
|
958
982
|
});
|
|
959
983
|
_vitest.test.call(void 0, "should update connection state", async (c) => {
|
|
960
984
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
@@ -985,14 +1009,16 @@ function runActorConnStateTests(driverTestConfig) {
|
|
|
985
1009
|
conn2.on("directMessage", (data) => {
|
|
986
1010
|
receivedMessages.push(data);
|
|
987
1011
|
});
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1012
|
+
await _vitest.vi.waitFor(async () => {
|
|
1013
|
+
const success = await conn1.sendToConnection(
|
|
1014
|
+
state2.id,
|
|
1015
|
+
"Hello from conn1"
|
|
1016
|
+
);
|
|
1017
|
+
_vitest.expect.call(void 0, success).toBe(true);
|
|
1018
|
+
_vitest.expect.call(void 0, receivedMessages.length).toBe(1);
|
|
1019
|
+
_vitest.expect.call(void 0, receivedMessages[0].from).toBe(state1.id);
|
|
1020
|
+
_vitest.expect.call(void 0, receivedMessages[0].message).toBe("Hello from conn1");
|
|
1021
|
+
});
|
|
996
1022
|
await conn1.dispose();
|
|
997
1023
|
await conn2.dispose();
|
|
998
1024
|
});
|
|
@@ -1071,7 +1097,7 @@ function runActorScheduleTests(driverTestConfig) {
|
|
|
1071
1097
|
|
|
1072
1098
|
// fixtures/driver-test-suite/sleep.ts
|
|
1073
1099
|
var SLEEP_TIMEOUT = 500;
|
|
1074
|
-
var sleep =
|
|
1100
|
+
var sleep = _chunk3Y45CIF4cjs.actor.call(void 0, {
|
|
1075
1101
|
state: { startCount: 0, sleepCount: 0 },
|
|
1076
1102
|
onStart: (c) => {
|
|
1077
1103
|
c.state.startCount += 1;
|
|
@@ -1097,7 +1123,7 @@ var sleep = _chunkMRZS2J4Xcjs.actor.call(void 0, {
|
|
|
1097
1123
|
sleepTimeout: SLEEP_TIMEOUT
|
|
1098
1124
|
}
|
|
1099
1125
|
});
|
|
1100
|
-
var sleepWithLongRpc =
|
|
1126
|
+
var sleepWithLongRpc = _chunk3Y45CIF4cjs.actor.call(void 0, {
|
|
1101
1127
|
state: { startCount: 0, sleepCount: 0 },
|
|
1102
1128
|
createVars: () => ({}),
|
|
1103
1129
|
onStart: (c) => {
|
|
@@ -1112,7 +1138,7 @@ var sleepWithLongRpc = _chunkMRZS2J4Xcjs.actor.call(void 0, {
|
|
|
1112
1138
|
},
|
|
1113
1139
|
longRunningRpc: async (c) => {
|
|
1114
1140
|
c.log.info("starting long running rpc");
|
|
1115
|
-
c.vars.longRunningResolve =
|
|
1141
|
+
c.vars.longRunningResolve = _chunk6EUWRXLTcjs.promiseWithResolvers.call(void 0, );
|
|
1116
1142
|
c.broadcast("waiting");
|
|
1117
1143
|
await c.vars.longRunningResolve.promise;
|
|
1118
1144
|
c.log.info("finished long running rpc");
|
|
@@ -1126,7 +1152,7 @@ var sleepWithLongRpc = _chunkMRZS2J4Xcjs.actor.call(void 0, {
|
|
|
1126
1152
|
sleepTimeout: SLEEP_TIMEOUT
|
|
1127
1153
|
}
|
|
1128
1154
|
});
|
|
1129
|
-
var sleepWithRawHttp =
|
|
1155
|
+
var sleepWithRawHttp = _chunk3Y45CIF4cjs.actor.call(void 0, {
|
|
1130
1156
|
state: { startCount: 0, sleepCount: 0, requestCount: 0 },
|
|
1131
1157
|
onStart: (c) => {
|
|
1132
1158
|
c.state.startCount += 1;
|
|
@@ -1161,7 +1187,7 @@ var sleepWithRawHttp = _chunkMRZS2J4Xcjs.actor.call(void 0, {
|
|
|
1161
1187
|
sleepTimeout: SLEEP_TIMEOUT
|
|
1162
1188
|
}
|
|
1163
1189
|
});
|
|
1164
|
-
var sleepWithRawWebSocket =
|
|
1190
|
+
var sleepWithRawWebSocket = _chunk3Y45CIF4cjs.actor.call(void 0, {
|
|
1165
1191
|
state: { startCount: 0, sleepCount: 0, connectionCount: 0 },
|
|
1166
1192
|
onStart: (c) => {
|
|
1167
1193
|
c.state.startCount += 1;
|
|
@@ -1224,7 +1250,7 @@ var sleepWithRawWebSocket = _chunkMRZS2J4Xcjs.actor.call(void 0, {
|
|
|
1224
1250
|
sleepTimeout: SLEEP_TIMEOUT
|
|
1225
1251
|
}
|
|
1226
1252
|
});
|
|
1227
|
-
var sleepWithNoSleepOption =
|
|
1253
|
+
var sleepWithNoSleepOption = _chunk3Y45CIF4cjs.actor.call(void 0, {
|
|
1228
1254
|
state: { startCount: 0, sleepCount: 0 },
|
|
1229
1255
|
onStart: (c) => {
|
|
1230
1256
|
c.state.startCount += 1;
|
|
@@ -1439,7 +1465,6 @@ function runActorSleepTests(driverTestConfig) {
|
|
|
1439
1465
|
_vitest.expect.call(void 0, counts.sleepCount).toBe(0);
|
|
1440
1466
|
_vitest.expect.call(void 0, counts.startCount).toBe(1);
|
|
1441
1467
|
ws.close();
|
|
1442
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1443
1468
|
await waitFor(driverTestConfig, SLEEP_TIMEOUT + 100);
|
|
1444
1469
|
{
|
|
1445
1470
|
const { startCount, sleepCount } = await sleepActor.getCounts();
|
|
@@ -1935,7 +1960,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
1935
1960
|
_vitest.describe.call(void 0, "Manager Inspector", () => {
|
|
1936
1961
|
_vitest.test.call(void 0, "should respond to ping", async (c) => {
|
|
1937
1962
|
const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
1938
|
-
const http =
|
|
1963
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
1939
1964
|
headers: {
|
|
1940
1965
|
Authorization: `Bearer token`
|
|
1941
1966
|
}
|
|
@@ -1949,7 +1974,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
1949
1974
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
1950
1975
|
await client.counter.create(["test-actor-1"]);
|
|
1951
1976
|
await client.counter.create(["test-actor-2"]);
|
|
1952
|
-
const http =
|
|
1977
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
1953
1978
|
headers: {
|
|
1954
1979
|
Authorization: `Bearer token`
|
|
1955
1980
|
}
|
|
@@ -1972,7 +1997,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
1972
1997
|
const actorKey2 = ["test-cursor-2"];
|
|
1973
1998
|
await client.counter.create(actorKey1);
|
|
1974
1999
|
await client.counter.create(actorKey2);
|
|
1975
|
-
const http =
|
|
2000
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
1976
2001
|
headers: {
|
|
1977
2002
|
Authorization: `Bearer token`
|
|
1978
2003
|
}
|
|
@@ -1997,7 +2022,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
1997
2022
|
});
|
|
1998
2023
|
_vitest.test.call(void 0, "should handle invalid limit parameter", async (c) => {
|
|
1999
2024
|
const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2000
|
-
const http =
|
|
2025
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
2001
2026
|
headers: {
|
|
2002
2027
|
Authorization: `Bearer token`
|
|
2003
2028
|
}
|
|
@@ -2009,7 +2034,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2009
2034
|
});
|
|
2010
2035
|
_vitest.test.call(void 0, "should create a new actor", async (c) => {
|
|
2011
2036
|
const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2012
|
-
const http =
|
|
2037
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
2013
2038
|
headers: {
|
|
2014
2039
|
Authorization: `Bearer token`
|
|
2015
2040
|
}
|
|
@@ -2033,7 +2058,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2033
2058
|
});
|
|
2034
2059
|
_vitest.test.call(void 0, "should get builds", async (c) => {
|
|
2035
2060
|
const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2036
|
-
const http =
|
|
2061
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
2037
2062
|
headers: {
|
|
2038
2063
|
Authorization: `Bearer token`
|
|
2039
2064
|
}
|
|
@@ -2051,7 +2076,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2051
2076
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2052
2077
|
const handle = await client.counter.create(["test-get-by-id"]);
|
|
2053
2078
|
const actorId = await handle.resolve();
|
|
2054
|
-
const http =
|
|
2079
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
2055
2080
|
headers: {
|
|
2056
2081
|
Authorization: `Bearer token`
|
|
2057
2082
|
}
|
|
@@ -2065,7 +2090,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2065
2090
|
});
|
|
2066
2091
|
_vitest.test.call(void 0, "should return 404 for non-existent actor", async (c) => {
|
|
2067
2092
|
const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2068
|
-
const http =
|
|
2093
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
2069
2094
|
headers: {
|
|
2070
2095
|
Authorization: `Bearer token`
|
|
2071
2096
|
}
|
|
@@ -2081,7 +2106,7 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2081
2106
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2082
2107
|
const handle = await client.counter.create(["test-bootstrap"]);
|
|
2083
2108
|
await handle.resolve();
|
|
2084
|
-
const http =
|
|
2109
|
+
const http = _chunkG4ABMAQYcjs.createManagerInspectorClient.call(void 0, `${endpoint}/inspect`, {
|
|
2085
2110
|
headers: {
|
|
2086
2111
|
Authorization: `Bearer token`
|
|
2087
2112
|
}
|
|
@@ -2103,10 +2128,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2103
2128
|
_vitest.test.call(void 0, "should handle actor not found", async (c) => {
|
|
2104
2129
|
const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2105
2130
|
const actorId = "non-existing";
|
|
2106
|
-
const http =
|
|
2131
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2107
2132
|
headers: {
|
|
2108
2133
|
Authorization: `Bearer token`,
|
|
2109
|
-
[
|
|
2134
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2110
2135
|
getForId: { name: "counter", actorId }
|
|
2111
2136
|
})
|
|
2112
2137
|
}
|
|
@@ -2118,10 +2143,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2118
2143
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2119
2144
|
const handle = await client.counter.create(["test-ping"]);
|
|
2120
2145
|
const actorId = await handle.resolve();
|
|
2121
|
-
const http =
|
|
2146
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2122
2147
|
headers: {
|
|
2123
2148
|
Authorization: `Bearer token`,
|
|
2124
|
-
[
|
|
2149
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2125
2150
|
getForId: { name: "counter", actorId }
|
|
2126
2151
|
})
|
|
2127
2152
|
}
|
|
@@ -2136,10 +2161,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2136
2161
|
const handle = await client.counter.create(["test-state"]);
|
|
2137
2162
|
const actorId = await handle.resolve();
|
|
2138
2163
|
await handle.increment(5);
|
|
2139
|
-
const http =
|
|
2164
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2140
2165
|
headers: {
|
|
2141
2166
|
Authorization: `Bearer token`,
|
|
2142
|
-
[
|
|
2167
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2143
2168
|
getForId: { name: "counter", actorId }
|
|
2144
2169
|
})
|
|
2145
2170
|
}
|
|
@@ -2158,10 +2183,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2158
2183
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2159
2184
|
const handle = await client.counter.create(["test-state-replace"]);
|
|
2160
2185
|
const actorId = await handle.resolve();
|
|
2161
|
-
const http =
|
|
2186
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2162
2187
|
headers: {
|
|
2163
2188
|
Authorization: `Bearer token`,
|
|
2164
|
-
[
|
|
2189
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2165
2190
|
getForId: { name: "counter", actorId }
|
|
2166
2191
|
})
|
|
2167
2192
|
}
|
|
@@ -2183,10 +2208,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2183
2208
|
const handle = await client.counter.create(["test-state-patch"]);
|
|
2184
2209
|
const actorId = await handle.resolve();
|
|
2185
2210
|
await handle.increment(3);
|
|
2186
|
-
const http =
|
|
2211
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2187
2212
|
headers: {
|
|
2188
2213
|
Authorization: `Bearer token`,
|
|
2189
|
-
[
|
|
2214
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2190
2215
|
getForId: { name: "counter", actorId }
|
|
2191
2216
|
})
|
|
2192
2217
|
}
|
|
@@ -2217,10 +2242,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2217
2242
|
const actorId = await handle.resolve();
|
|
2218
2243
|
handle.connect();
|
|
2219
2244
|
await handle.increment(10);
|
|
2220
|
-
const http =
|
|
2245
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2221
2246
|
headers: {
|
|
2222
2247
|
Authorization: `Bearer token`,
|
|
2223
|
-
[
|
|
2248
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2224
2249
|
getForId: { name: "counter", actorId }
|
|
2225
2250
|
})
|
|
2226
2251
|
}
|
|
@@ -2242,10 +2267,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2242
2267
|
const actorId = await handle.resolve();
|
|
2243
2268
|
handle.connect();
|
|
2244
2269
|
await handle.increment(10);
|
|
2245
|
-
const http =
|
|
2270
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2246
2271
|
headers: {
|
|
2247
2272
|
Authorization: `Bearer token`,
|
|
2248
|
-
[
|
|
2273
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2249
2274
|
getForId: { name: "counter", actorId }
|
|
2250
2275
|
})
|
|
2251
2276
|
}
|
|
@@ -2268,10 +2293,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2268
2293
|
const actorId = await handle.resolve();
|
|
2269
2294
|
handle.connect();
|
|
2270
2295
|
await handle.increment(10);
|
|
2271
|
-
const http =
|
|
2296
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2272
2297
|
headers: {
|
|
2273
2298
|
Authorization: `Bearer token`,
|
|
2274
|
-
[
|
|
2299
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2275
2300
|
getForId: { name: "counter", actorId }
|
|
2276
2301
|
})
|
|
2277
2302
|
}
|
|
@@ -2296,10 +2321,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2296
2321
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2297
2322
|
const handle = await client.counter.create(["test-rpcs"]);
|
|
2298
2323
|
const actorId = await handle.resolve();
|
|
2299
|
-
const http =
|
|
2324
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2300
2325
|
headers: {
|
|
2301
2326
|
Authorization: `Bearer token`,
|
|
2302
|
-
[
|
|
2327
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2303
2328
|
getForId: { name: "counter", actorId }
|
|
2304
2329
|
})
|
|
2305
2330
|
}
|
|
@@ -2317,10 +2342,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2317
2342
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2318
2343
|
const handle = await client.counter.create(["test-db"]);
|
|
2319
2344
|
const actorId = await handle.resolve();
|
|
2320
|
-
const http =
|
|
2345
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2321
2346
|
headers: {
|
|
2322
2347
|
Authorization: `Bearer token`,
|
|
2323
|
-
[
|
|
2348
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2324
2349
|
getForId: { name: "counter", actorId }
|
|
2325
2350
|
})
|
|
2326
2351
|
}
|
|
@@ -2341,10 +2366,10 @@ function runActorInspectorTests(driverTestConfig) {
|
|
|
2341
2366
|
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2342
2367
|
const handle = await client.counter.create(["test-db-query"]);
|
|
2343
2368
|
const actorId = await handle.resolve();
|
|
2344
|
-
const http =
|
|
2369
|
+
const http = _chunkG4ABMAQYcjs.createActorInspectorClient.call(void 0, `${endpoint}/actors/inspect`, {
|
|
2345
2370
|
headers: {
|
|
2346
2371
|
Authorization: `Bearer token`,
|
|
2347
|
-
[
|
|
2372
|
+
[_chunkSAZCNSVYcjs.HEADER_ACTOR_QUERY]: JSON.stringify({
|
|
2348
2373
|
getForId: { name: "counter", actorId }
|
|
2349
2374
|
})
|
|
2350
2375
|
}
|
|
@@ -2507,6 +2532,103 @@ function runActorOnStateChangeTests(driverTestConfig) {
|
|
|
2507
2532
|
});
|
|
2508
2533
|
}
|
|
2509
2534
|
|
|
2535
|
+
// src/driver-test-suite/tests/actor-reconnect.ts
|
|
2536
|
+
|
|
2537
|
+
function runActorReconnectTests(driverTestConfig) {
|
|
2538
|
+
_vitest.describe.call(void 0, "Actor Reconnection Tests", () => {
|
|
2539
|
+
_vitest.test.call(void 0, "should reconnect and preserve connection state after non-clean disconnect", async (c) => {
|
|
2540
|
+
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2541
|
+
const handle = client.counterConn.getOrCreate(["test-reconnect"]);
|
|
2542
|
+
const connection = handle.connect();
|
|
2543
|
+
await connection.increment(5);
|
|
2544
|
+
const connCount1 = await connection.getConnectionCount();
|
|
2545
|
+
_vitest.expect.call(void 0, connCount1).toBe(1);
|
|
2546
|
+
const connRaw = connection;
|
|
2547
|
+
await forceUncleanDisconnect(
|
|
2548
|
+
endpoint,
|
|
2549
|
+
connRaw.actorId,
|
|
2550
|
+
connRaw.connectionId
|
|
2551
|
+
);
|
|
2552
|
+
await _vitest.vi.waitFor(
|
|
2553
|
+
async () => {
|
|
2554
|
+
const countAfterReconnect = await connection.getCount();
|
|
2555
|
+
_vitest.expect.call(void 0, countAfterReconnect).toBe(5);
|
|
2556
|
+
},
|
|
2557
|
+
{ timeout: 5e3, interval: 100 }
|
|
2558
|
+
);
|
|
2559
|
+
const connCount2 = await connection.getConnectionCount();
|
|
2560
|
+
_vitest.expect.call(void 0, connCount2).toBe(1);
|
|
2561
|
+
const newCount = await connection.getCount();
|
|
2562
|
+
_vitest.expect.call(void 0, newCount).toBe(5);
|
|
2563
|
+
await connection.dispose();
|
|
2564
|
+
});
|
|
2565
|
+
_vitest.test.call(void 0, "should not preserve connection state after clean disconnect", async (c) => {
|
|
2566
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
2567
|
+
const handle = client.counterConn.getOrCreate(["test-clean-disconnect"]);
|
|
2568
|
+
const connection = handle.connect();
|
|
2569
|
+
await connection.increment(10);
|
|
2570
|
+
const connCount1 = await connection.getConnectionCount();
|
|
2571
|
+
_vitest.expect.call(void 0, connCount1).toBe(1);
|
|
2572
|
+
await connection.dispose();
|
|
2573
|
+
await _vitest.vi.waitFor(
|
|
2574
|
+
async () => {
|
|
2575
|
+
const handle2 = client.counterConn.get(["test-clean-disconnect"]);
|
|
2576
|
+
const connCount = await handle2.getConnectionCount();
|
|
2577
|
+
_vitest.expect.call(void 0, connCount).toBe(1);
|
|
2578
|
+
},
|
|
2579
|
+
{ timeout: 5e3 }
|
|
2580
|
+
);
|
|
2581
|
+
const connection2 = handle.connect();
|
|
2582
|
+
const countNewConnection = await connection2.getCount();
|
|
2583
|
+
_vitest.expect.call(void 0, countNewConnection).toBe(0);
|
|
2584
|
+
const connCount3 = await connection2.getConnectionCount();
|
|
2585
|
+
_vitest.expect.call(void 0, connCount3).toBe(1);
|
|
2586
|
+
await connection2.dispose();
|
|
2587
|
+
});
|
|
2588
|
+
_vitest.test.call(void 0, "should handle multiple non-clean disconnects and reconnects", async (c) => {
|
|
2589
|
+
const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
2590
|
+
const handle = client.counterConn.getOrCreate([
|
|
2591
|
+
"test-multiple-reconnect"
|
|
2592
|
+
]);
|
|
2593
|
+
const connection = handle.connect();
|
|
2594
|
+
await connection.setCount(100);
|
|
2595
|
+
for (let i = 0; i < 3; i++) {
|
|
2596
|
+
await connection.increment(1);
|
|
2597
|
+
const connRaw = connection;
|
|
2598
|
+
await forceUncleanDisconnect(
|
|
2599
|
+
endpoint,
|
|
2600
|
+
connRaw.actorId,
|
|
2601
|
+
connRaw.connectionId
|
|
2602
|
+
);
|
|
2603
|
+
await _vitest.vi.waitFor(
|
|
2604
|
+
async () => {
|
|
2605
|
+
const countAfter = await connection.getCount();
|
|
2606
|
+
_vitest.expect.call(void 0, countAfter).toBe(101 + i);
|
|
2607
|
+
},
|
|
2608
|
+
{ timeout: 5e3 }
|
|
2609
|
+
);
|
|
2610
|
+
const connCount = await connection.getConnectionCount();
|
|
2611
|
+
_vitest.expect.call(void 0, connCount).toBe(1);
|
|
2612
|
+
}
|
|
2613
|
+
const finalCount = await connection.getCount();
|
|
2614
|
+
_vitest.expect.call(void 0, finalCount).toBe(103);
|
|
2615
|
+
await connection.dispose();
|
|
2616
|
+
});
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
async function forceUncleanDisconnect(endpoint, actorId, connId) {
|
|
2620
|
+
const response = await fetch(
|
|
2621
|
+
`${endpoint}/.test/force-disconnect?actor=${actorId}&conn=${connId}`,
|
|
2622
|
+
{
|
|
2623
|
+
method: "POST"
|
|
2624
|
+
}
|
|
2625
|
+
);
|
|
2626
|
+
if (!response.ok) {
|
|
2627
|
+
const text = await response.text();
|
|
2628
|
+
throw new Error(`Failed to force disconnect: ${text}`);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2510
2632
|
// src/driver-test-suite/tests/actor-vars.ts
|
|
2511
2633
|
|
|
2512
2634
|
function runActorVarsTests(driverTestConfig) {
|
|
@@ -3549,29 +3671,6 @@ function runRawWebSocketTests(driverTestConfig) {
|
|
|
3549
3671
|
_vitest.expect.call(void 0, welcomeMessage.type).toBe("welcome");
|
|
3550
3672
|
ws.close();
|
|
3551
3673
|
});
|
|
3552
|
-
_vitest.test.call(void 0, "should pass connection parameters through subprotocols", async (c) => {
|
|
3553
|
-
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3554
|
-
const testParams = { userId: "test123", role: "admin" };
|
|
3555
|
-
const actor2 = client.rawWebSocketActor.getOrCreate(["params"], {
|
|
3556
|
-
params: testParams
|
|
3557
|
-
});
|
|
3558
|
-
const ws = await actor2.websocket();
|
|
3559
|
-
await new Promise((resolve) => {
|
|
3560
|
-
ws.addEventListener("open", () => resolve(), { once: true });
|
|
3561
|
-
});
|
|
3562
|
-
ws.send(JSON.stringify({ type: "getAuthData" }));
|
|
3563
|
-
const response = await new Promise((resolve, reject) => {
|
|
3564
|
-
ws.addEventListener("message", (event) => {
|
|
3565
|
-
const data = JSON.parse(event.data);
|
|
3566
|
-
if (data.type === "authData") {
|
|
3567
|
-
resolve(data);
|
|
3568
|
-
}
|
|
3569
|
-
});
|
|
3570
|
-
ws.addEventListener("close", reject);
|
|
3571
|
-
});
|
|
3572
|
-
_vitest.expect.call(void 0, response).toBeDefined();
|
|
3573
|
-
ws.close();
|
|
3574
|
-
});
|
|
3575
3674
|
_vitest.test.call(void 0, "should handle connection close properly", async (c) => {
|
|
3576
3675
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
3577
3676
|
const actor2 = client.rawWebSocketActor.getOrCreate(["close-test"]);
|
|
@@ -3777,15 +3876,18 @@ function runDriverTests(driverTestConfigPartial) {
|
|
|
3777
3876
|
clientType
|
|
3778
3877
|
};
|
|
3779
3878
|
_vitest.describe.call(void 0, `client type (${clientType})`, () => {
|
|
3879
|
+
var _a;
|
|
3780
3880
|
runActorDriverTests(driverTestConfig);
|
|
3781
3881
|
runManagerDriverTests(driverTestConfig);
|
|
3782
|
-
|
|
3882
|
+
const transports = ((_a = driverTestConfig.skip) == null ? void 0 : _a.sse) ? ["websocket"] : ["websocket", "sse"];
|
|
3883
|
+
for (const transport of transports) {
|
|
3783
3884
|
_vitest.describe.call(void 0, `transport (${transport})`, () => {
|
|
3784
3885
|
runActorConnTests({
|
|
3785
3886
|
...driverTestConfig,
|
|
3786
3887
|
transport
|
|
3787
3888
|
});
|
|
3788
3889
|
runActorConnStateTests({ ...driverTestConfig, transport });
|
|
3890
|
+
runActorReconnectTests({ ...driverTestConfig, transport });
|
|
3789
3891
|
runRequestAccessTests({ ...driverTestConfig, transport });
|
|
3790
3892
|
runActorDriverTestsWithTransport({ ...driverTestConfig, transport });
|
|
3791
3893
|
});
|
|
@@ -3828,7 +3930,7 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
3828
3930
|
};
|
|
3829
3931
|
} else {
|
|
3830
3932
|
let upgradeWebSocket;
|
|
3831
|
-
const config =
|
|
3933
|
+
const config = _chunkDFS77KAAcjs.RunConfigSchema.parse({
|
|
3832
3934
|
driver,
|
|
3833
3935
|
getUpgradeWebSocket: () => upgradeWebSocket,
|
|
3834
3936
|
inspector: {
|
|
@@ -3837,15 +3939,16 @@ async function createTestRuntime(registryPath, driverFactory) {
|
|
|
3837
3939
|
}
|
|
3838
3940
|
});
|
|
3839
3941
|
const managerDriver = driver.manager(registry.config, config);
|
|
3840
|
-
|
|
3942
|
+
_chunkG4ABMAQYcjs.configureInspectorAccessToken.call(void 0, config, managerDriver);
|
|
3943
|
+
const { router } = _chunk3Y45CIF4cjs.createManagerRouter.call(void 0,
|
|
3841
3944
|
registry.config,
|
|
3842
3945
|
config,
|
|
3843
3946
|
managerDriver,
|
|
3844
|
-
|
|
3947
|
+
void 0
|
|
3845
3948
|
);
|
|
3846
3949
|
const nodeWebSocket = _nodews.createNodeWebSocket.call(void 0, { app: router });
|
|
3847
3950
|
upgradeWebSocket = nodeWebSocket.upgradeWebSocket;
|
|
3848
|
-
const port = await
|
|
3951
|
+
const port = await _chunkTZGUSEIJcjs.getPort.call(void 0, );
|
|
3849
3952
|
const server = _nodeserver.serve.call(void 0, {
|
|
3850
3953
|
fetch: router.fetch,
|
|
3851
3954
|
hostname: "127.0.0.1",
|