rivetkit 2.0.24-rc.1 → 2.0.25-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 +6 -0
- package/dist/schemas/actor-persist/v2.ts +9 -3
- package/dist/schemas/actor-persist/v3.ts +280 -0
- package/dist/schemas/client-protocol/v1.ts +6 -0
- package/dist/schemas/client-protocol/v2.ts +438 -0
- package/dist/schemas/file-system-driver/v1.ts +6 -0
- package/dist/schemas/file-system-driver/v2.ts +142 -0
- package/dist/tsup/actor/errors.cjs +2 -4
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +7 -10
- package/dist/tsup/actor/errors.d.ts +7 -10
- package/dist/tsup/actor/errors.js +9 -11
- package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.cts → actor-router-consts-DzI2szci.d.cts} +5 -9
- package/dist/tsup/{actor-router-consts-B3Lu87yJ.d.ts → actor-router-consts-DzI2szci.d.ts} +5 -9
- package/dist/tsup/{chunk-ZTH3KYFH.cjs → chunk-3FG5OJ3G.cjs} +3 -3
- package/dist/tsup/{chunk-ZTH3KYFH.cjs.map → chunk-3FG5OJ3G.cjs.map} +1 -1
- package/dist/tsup/{chunk-BLK27ES3.js → chunk-6JN6W6G3.js} +44 -56
- package/dist/tsup/chunk-6JN6W6G3.js.map +1 -0
- package/dist/tsup/chunk-7IBNNGQ2.js +514 -0
- package/dist/tsup/chunk-7IBNNGQ2.js.map +1 -0
- package/dist/tsup/{chunk-36JJ4IQB.cjs → chunk-AZATXPR4.cjs} +4 -8
- package/dist/tsup/chunk-AZATXPR4.cjs.map +1 -0
- package/dist/tsup/chunk-B7MENRD5.cjs +5694 -0
- package/dist/tsup/chunk-B7MENRD5.cjs.map +1 -0
- package/dist/tsup/{chunk-BOMZS2TJ.js → chunk-BBVFDEYD.js} +9 -9
- package/dist/tsup/chunk-BBVFDEYD.js.map +1 -0
- package/dist/tsup/{chunk-KSRXX3Z4.cjs → chunk-D6762AOA.cjs} +20 -25
- package/dist/tsup/chunk-D6762AOA.cjs.map +1 -0
- package/dist/tsup/{chunk-2JYPS5YM.cjs → chunk-E63WZNMR.cjs} +6 -6
- package/dist/tsup/chunk-E63WZNMR.cjs.map +1 -0
- package/dist/tsup/{chunk-YBG6R7LX.js → chunk-EDGN4OC7.js} +3 -7
- package/dist/tsup/chunk-EDGN4OC7.js.map +1 -0
- package/dist/tsup/{chunk-BYMKMOBS.js → chunk-FLOQ3UWM.js} +1844 -1681
- package/dist/tsup/chunk-FLOQ3UWM.js.map +1 -0
- package/dist/tsup/{chunk-7L65NNWP.cjs → chunk-H7GV5DIW.cjs} +187 -185
- package/dist/tsup/chunk-H7GV5DIW.cjs.map +1 -0
- package/dist/tsup/{chunk-227FEWMB.js → chunk-HZYZ7JSF.js} +3322 -2251
- package/dist/tsup/chunk-HZYZ7JSF.js.map +1 -0
- package/dist/tsup/{chunk-FX7TWFQR.js → chunk-IDJK7ILQ.js} +2 -6
- package/dist/tsup/chunk-IDJK7ILQ.js.map +1 -0
- package/dist/tsup/{chunk-VHGY7PU5.cjs → chunk-ILFXA4AL.cjs} +1900 -1737
- package/dist/tsup/chunk-ILFXA4AL.cjs.map +1 -0
- package/dist/tsup/chunk-MV6M3FDL.cjs +514 -0
- package/dist/tsup/chunk-MV6M3FDL.cjs.map +1 -0
- package/dist/tsup/{chunk-PLUN2NQT.js → chunk-NWBKMCWC.js} +189 -187
- package/dist/tsup/chunk-NWBKMCWC.js.map +1 -0
- package/dist/tsup/{chunk-CD33GT6Z.js → chunk-QIHBDXTO.js} +2 -2
- package/dist/tsup/{chunk-G64QUEDJ.js → chunk-W6RDS6NW.js} +23 -28
- package/dist/tsup/chunk-W6RDS6NW.js.map +1 -0
- package/dist/tsup/{chunk-INNFK746.cjs → chunk-WQU4M4ZC.cjs} +10 -14
- package/dist/tsup/chunk-WQU4M4ZC.cjs.map +1 -0
- package/dist/tsup/{chunk-SHVX2QUR.cjs → chunk-XKZA47XS.cjs} +17 -17
- package/dist/tsup/chunk-XKZA47XS.cjs.map +1 -0
- package/dist/tsup/{chunk-HHFKKVLR.cjs → chunk-YHWIOWVA.cjs} +45 -57
- package/dist/tsup/chunk-YHWIOWVA.cjs.map +1 -0
- package/dist/tsup/{chunk-YBHYXIP6.js → chunk-YVL6IRUM.js} +3 -3
- package/dist/tsup/chunk-YVL6IRUM.js.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -7
- package/dist/tsup/client/mod.d.ts +5 -7
- 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/{conn-B3Vhbgnd.d.ts → config-BRDYDraU.d.cts} +1119 -1047
- package/dist/tsup/{conn-DJWL3nGx.d.cts → config-Bo-blHpJ.d.ts} +1119 -1047
- package/dist/tsup/driver-helpers/mod.cjs +5 -13
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +11 -9
- package/dist/tsup/driver-helpers/mod.d.ts +11 -9
- package/dist/tsup/driver-helpers/mod.js +14 -22
- package/dist/tsup/driver-test-suite/mod.cjs +474 -303
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +6 -9
- package/dist/tsup/driver-test-suite/mod.d.ts +6 -9
- package/dist/tsup/driver-test-suite/mod.js +1085 -914
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.d.cts +5 -7
- package/dist/tsup/inspector/mod.d.ts +5 -7
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/mod.cjs +10 -16
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +23 -25
- package/dist/tsup/mod.d.ts +23 -25
- package/dist/tsup/mod.js +17 -23
- package/dist/tsup/test/mod.cjs +11 -11
- package/dist/tsup/test/mod.d.cts +4 -6
- package/dist/tsup/test/mod.d.ts +4 -6
- package/dist/tsup/test/mod.js +10 -10
- package/dist/tsup/utils.cjs +3 -5
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +1 -2
- package/dist/tsup/utils.d.ts +1 -2
- package/dist/tsup/utils.js +2 -4
- package/package.json +13 -6
- package/src/actor/config.ts +56 -44
- package/src/actor/conn/driver.ts +61 -0
- package/src/actor/conn/drivers/http.ts +17 -0
- package/src/actor/conn/drivers/raw-request.ts +24 -0
- package/src/actor/conn/drivers/raw-websocket.ts +65 -0
- package/src/actor/conn/drivers/websocket.ts +129 -0
- package/src/actor/conn/mod.ts +232 -0
- package/src/actor/conn/persisted.ts +81 -0
- package/src/actor/conn/state-manager.ts +196 -0
- package/src/actor/contexts/action.ts +23 -0
- package/src/actor/{context.ts → contexts/actor.ts} +19 -8
- package/src/actor/contexts/conn-init.ts +31 -0
- package/src/actor/contexts/conn.ts +48 -0
- package/src/actor/contexts/create-conn-state.ts +13 -0
- package/src/actor/contexts/on-before-connect.ts +13 -0
- package/src/actor/contexts/on-connect.ts +22 -0
- package/src/actor/contexts/request.ts +48 -0
- package/src/actor/contexts/websocket.ts +48 -0
- package/src/actor/definition.ts +3 -3
- package/src/actor/driver.ts +36 -5
- package/src/actor/errors.ts +19 -24
- package/src/actor/instance/connection-manager.ts +465 -0
- package/src/actor/instance/event-manager.ts +292 -0
- package/src/actor/instance/kv.ts +15 -0
- package/src/actor/instance/mod.ts +1107 -0
- package/src/actor/instance/persisted.ts +67 -0
- package/src/actor/instance/schedule-manager.ts +349 -0
- package/src/actor/instance/state-manager.ts +502 -0
- package/src/actor/mod.ts +13 -16
- package/src/actor/protocol/old.ts +131 -43
- package/src/actor/protocol/serde.ts +19 -4
- package/src/actor/router-endpoints.ts +61 -586
- package/src/actor/router-websocket-endpoints.ts +408 -0
- package/src/actor/router.ts +63 -197
- package/src/actor/schedule.ts +1 -1
- package/src/client/actor-conn.ts +183 -249
- package/src/client/actor-handle.ts +29 -6
- package/src/client/client.ts +0 -4
- package/src/client/config.ts +1 -4
- package/src/client/mod.ts +0 -1
- package/src/client/raw-utils.ts +3 -3
- package/src/client/utils.ts +85 -39
- package/src/common/actor-router-consts.ts +5 -12
- package/src/common/{inline-websocket-adapter2.ts → inline-websocket-adapter.ts} +26 -48
- package/src/common/log.ts +1 -1
- package/src/common/router.ts +28 -17
- package/src/common/utils.ts +2 -0
- package/src/driver-helpers/mod.ts +7 -10
- package/src/driver-helpers/utils.ts +18 -9
- package/src/driver-test-suite/mod.ts +26 -50
- package/src/driver-test-suite/test-inline-client-driver.ts +27 -51
- package/src/driver-test-suite/tests/actor-conn-hibernation.ts +150 -0
- package/src/driver-test-suite/tests/actor-conn-state.ts +1 -4
- package/src/driver-test-suite/tests/actor-conn.ts +5 -9
- package/src/driver-test-suite/tests/actor-destroy.ts +294 -0
- package/src/driver-test-suite/tests/actor-driver.ts +0 -7
- package/src/driver-test-suite/tests/actor-handle.ts +12 -12
- package/src/driver-test-suite/tests/actor-metadata.ts +1 -1
- package/src/driver-test-suite/tests/manager-driver.ts +1 -1
- package/src/driver-test-suite/tests/raw-http-direct-registry.ts +8 -8
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +6 -5
- package/src/driver-test-suite/tests/raw-http.ts +5 -5
- package/src/driver-test-suite/tests/raw-websocket-direct-registry.ts +7 -7
- package/src/driver-test-suite/tests/request-access.ts +4 -4
- package/src/driver-test-suite/utils.ts +6 -10
- package/src/drivers/engine/actor-driver.ts +614 -424
- package/src/drivers/engine/mod.ts +0 -1
- package/src/drivers/file-system/actor.ts +24 -12
- package/src/drivers/file-system/global-state.ts +427 -37
- package/src/drivers/file-system/manager.ts +71 -83
- package/src/drivers/file-system/mod.ts +3 -0
- package/src/drivers/file-system/utils.ts +18 -8
- package/src/engine-process/mod.ts +38 -38
- package/src/inspector/utils.ts +7 -5
- package/src/manager/driver.ts +11 -4
- package/src/manager/gateway.ts +4 -29
- package/src/manager/protocol/mod.ts +0 -2
- package/src/manager/protocol/query.ts +0 -4
- package/src/manager/router.ts +67 -64
- package/src/manager-api/actors.ts +13 -0
- package/src/mod.ts +1 -3
- package/src/registry/mod.ts +20 -20
- package/src/registry/serve.ts +9 -14
- package/src/remote-manager-driver/actor-websocket-client.ts +1 -16
- package/src/remote-manager-driver/api-endpoints.ts +13 -1
- package/src/remote-manager-driver/api-utils.ts +8 -0
- package/src/remote-manager-driver/metadata.ts +58 -0
- package/src/remote-manager-driver/mod.ts +47 -62
- package/src/remote-manager-driver/ws-proxy.ts +1 -1
- package/src/schemas/actor-persist/mod.ts +1 -1
- package/src/schemas/actor-persist/versioned.ts +56 -31
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +41 -21
- package/src/schemas/client-protocol-zod/mod.ts +103 -0
- package/src/schemas/file-system-driver/mod.ts +1 -1
- package/src/schemas/file-system-driver/versioned.ts +42 -19
- package/src/serde.ts +33 -11
- package/src/test/mod.ts +7 -3
- package/src/utils/node.ts +173 -0
- package/src/utils.ts +0 -4
- package/dist/tsup/chunk-227FEWMB.js.map +0 -1
- package/dist/tsup/chunk-2JYPS5YM.cjs.map +0 -1
- package/dist/tsup/chunk-36JJ4IQB.cjs.map +0 -1
- package/dist/tsup/chunk-7L65NNWP.cjs.map +0 -1
- package/dist/tsup/chunk-BLK27ES3.js.map +0 -1
- package/dist/tsup/chunk-BOMZS2TJ.js.map +0 -1
- package/dist/tsup/chunk-BYMKMOBS.js.map +0 -1
- package/dist/tsup/chunk-FX7TWFQR.js.map +0 -1
- package/dist/tsup/chunk-G64QUEDJ.js.map +0 -1
- package/dist/tsup/chunk-HHFKKVLR.cjs.map +0 -1
- package/dist/tsup/chunk-INNFK746.cjs.map +0 -1
- package/dist/tsup/chunk-KSRXX3Z4.cjs.map +0 -1
- package/dist/tsup/chunk-O44LFKSB.cjs +0 -4623
- package/dist/tsup/chunk-O44LFKSB.cjs.map +0 -1
- package/dist/tsup/chunk-PLUN2NQT.js.map +0 -1
- package/dist/tsup/chunk-S4UJG7ZE.js +0 -1119
- package/dist/tsup/chunk-S4UJG7ZE.js.map +0 -1
- package/dist/tsup/chunk-SHVX2QUR.cjs.map +0 -1
- package/dist/tsup/chunk-VFB23BYZ.cjs +0 -1119
- package/dist/tsup/chunk-VFB23BYZ.cjs.map +0 -1
- package/dist/tsup/chunk-VHGY7PU5.cjs.map +0 -1
- package/dist/tsup/chunk-YBG6R7LX.js.map +0 -1
- package/dist/tsup/chunk-YBHYXIP6.js.map +0 -1
- package/src/actor/action.ts +0 -178
- package/src/actor/conn-drivers.ts +0 -216
- package/src/actor/conn-socket.ts +0 -8
- package/src/actor/conn.ts +0 -272
- package/src/actor/instance.ts +0 -2336
- package/src/actor/persisted.ts +0 -49
- package/src/actor/unstable-react.ts +0 -110
- package/src/driver-test-suite/tests/actor-reconnect.ts +0 -170
- package/src/drivers/engine/kv.ts +0 -3
- package/src/manager/hono-websocket-adapter.ts +0 -393
- /package/dist/tsup/{chunk-CD33GT6Z.js.map → chunk-QIHBDXTO.js.map} +0 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from "vitest";
|
|
2
|
+
import type { ActorError } from "@/client/mod";
|
|
3
|
+
import type { DriverTestConfig } from "../mod";
|
|
4
|
+
import { setupDriverTest } from "../utils";
|
|
5
|
+
|
|
6
|
+
export function runActorDestroyTests(driverTestConfig: DriverTestConfig) {
|
|
7
|
+
describe("Actor Destroy Tests", () => {
|
|
8
|
+
test("actor destroy clears state (without connect)", async (c) => {
|
|
9
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
10
|
+
|
|
11
|
+
const actorKey = "test-destroy-without-connect";
|
|
12
|
+
|
|
13
|
+
// Get destroy observer
|
|
14
|
+
const observer = client.destroyObserver.getOrCreate(["observer"]);
|
|
15
|
+
await observer.reset();
|
|
16
|
+
|
|
17
|
+
// Create actor
|
|
18
|
+
const destroyActor = client.destroyActor.getOrCreate([actorKey]);
|
|
19
|
+
|
|
20
|
+
// Update state and save immediately
|
|
21
|
+
await destroyActor.setValue(42);
|
|
22
|
+
|
|
23
|
+
// Verify state was saved
|
|
24
|
+
const value = await destroyActor.getValue();
|
|
25
|
+
expect(value).toBe(42);
|
|
26
|
+
|
|
27
|
+
// Get actor ID before destroying
|
|
28
|
+
const actorId = await destroyActor.resolve();
|
|
29
|
+
|
|
30
|
+
// Destroy the actor
|
|
31
|
+
await destroyActor.destroy();
|
|
32
|
+
|
|
33
|
+
// Wait until the observer confirms the actor was destroyed
|
|
34
|
+
await vi.waitFor(async () => {
|
|
35
|
+
const wasDestroyed = await observer.wasDestroyed(actorKey);
|
|
36
|
+
expect(wasDestroyed, "actor onDestroy not called").toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Wait until the actor is fully cleaned up (getForId returns error)
|
|
40
|
+
await vi.waitFor(async () => {
|
|
41
|
+
let actorRunning = false;
|
|
42
|
+
try {
|
|
43
|
+
await client.destroyActor.getForId(actorId).getValue();
|
|
44
|
+
actorRunning = true;
|
|
45
|
+
} catch (err) {
|
|
46
|
+
expect((err as ActorError).group).toBe("actor");
|
|
47
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
expect(actorRunning, "actor still running").toBeFalsy();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Verify actor no longer exists via getForId
|
|
54
|
+
let existsById = false;
|
|
55
|
+
try {
|
|
56
|
+
await client.destroyActor.getForId(actorId).getValue();
|
|
57
|
+
existsById = true;
|
|
58
|
+
} catch (err) {
|
|
59
|
+
expect((err as ActorError).group).toBe("actor");
|
|
60
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
61
|
+
}
|
|
62
|
+
expect(
|
|
63
|
+
existsById,
|
|
64
|
+
"actor should not exist after destroy",
|
|
65
|
+
).toBeFalsy();
|
|
66
|
+
|
|
67
|
+
// Verify actor no longer exists via get
|
|
68
|
+
let existsByKey = false;
|
|
69
|
+
try {
|
|
70
|
+
await client.destroyActor
|
|
71
|
+
.get(["test-destroy-without-connect"])
|
|
72
|
+
.resolve();
|
|
73
|
+
existsByKey = true;
|
|
74
|
+
} catch (err) {
|
|
75
|
+
expect((err as ActorError).group).toBe("actor");
|
|
76
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
77
|
+
}
|
|
78
|
+
expect(
|
|
79
|
+
existsByKey,
|
|
80
|
+
"actor should not exist after destroy",
|
|
81
|
+
).toBeFalsy();
|
|
82
|
+
|
|
83
|
+
// Create new actor with same key using getOrCreate
|
|
84
|
+
const newActor = client.destroyActor.getOrCreate([
|
|
85
|
+
"test-destroy-without-connect",
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
// Verify state is fresh (default value, not the old value)
|
|
89
|
+
const newValue = await newActor.getValue();
|
|
90
|
+
expect(newValue).toBe(0);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("actor destroy clears state (with connect)", async (c) => {
|
|
94
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
95
|
+
|
|
96
|
+
const actorKey = "test-destroy-with-connect";
|
|
97
|
+
|
|
98
|
+
// Get destroy observer
|
|
99
|
+
const observer = client.destroyObserver.getOrCreate(["observer"]);
|
|
100
|
+
await observer.reset();
|
|
101
|
+
|
|
102
|
+
// Create actor handle
|
|
103
|
+
const destroyActorHandle = client.destroyActor.getOrCreate([
|
|
104
|
+
actorKey,
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
// Get actor ID before destroying
|
|
108
|
+
const actorId = await destroyActorHandle.resolve();
|
|
109
|
+
|
|
110
|
+
// Create persistent connection
|
|
111
|
+
const destroyActor = destroyActorHandle.connect();
|
|
112
|
+
|
|
113
|
+
// Update state and save immediately
|
|
114
|
+
await destroyActor.setValue(99);
|
|
115
|
+
|
|
116
|
+
// Verify state was saved
|
|
117
|
+
const value = await destroyActor.getValue();
|
|
118
|
+
expect(value).toBe(99);
|
|
119
|
+
|
|
120
|
+
// Destroy the actor
|
|
121
|
+
await destroyActor.destroy();
|
|
122
|
+
|
|
123
|
+
// Dispose the connection
|
|
124
|
+
await destroyActor.dispose();
|
|
125
|
+
|
|
126
|
+
// Wait until the observer confirms the actor was destroyed
|
|
127
|
+
await vi.waitFor(async () => {
|
|
128
|
+
const wasDestroyed = await observer.wasDestroyed(actorKey);
|
|
129
|
+
expect(wasDestroyed, "actor onDestroy not called").toBeTruthy();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Wait until the actor is fully cleaned up (getForId returns error)
|
|
133
|
+
await vi.waitFor(async () => {
|
|
134
|
+
let actorRunning = false;
|
|
135
|
+
try {
|
|
136
|
+
await client.destroyActor.getForId(actorId).getValue();
|
|
137
|
+
actorRunning = true;
|
|
138
|
+
} catch (err) {
|
|
139
|
+
expect((err as ActorError).group).toBe("actor");
|
|
140
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
expect(actorRunning, "actor still running").toBeFalsy();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Verify actor no longer exists via getForId
|
|
147
|
+
let existsById = false;
|
|
148
|
+
try {
|
|
149
|
+
await client.destroyActor.getForId(actorId).getValue();
|
|
150
|
+
existsById = true;
|
|
151
|
+
} catch (err) {
|
|
152
|
+
expect((err as ActorError).group).toBe("actor");
|
|
153
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
154
|
+
}
|
|
155
|
+
expect(
|
|
156
|
+
existsById,
|
|
157
|
+
"actor should not exist after destroy",
|
|
158
|
+
).toBeFalsy();
|
|
159
|
+
|
|
160
|
+
// Verify actor no longer exists via get
|
|
161
|
+
let existsByKey = false;
|
|
162
|
+
try {
|
|
163
|
+
await client.destroyActor
|
|
164
|
+
.get(["test-destroy-with-connect"])
|
|
165
|
+
.resolve();
|
|
166
|
+
existsByKey = true;
|
|
167
|
+
} catch (err) {
|
|
168
|
+
expect((err as ActorError).group).toBe("actor");
|
|
169
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
170
|
+
}
|
|
171
|
+
expect(
|
|
172
|
+
existsByKey,
|
|
173
|
+
"actor should not exist after destroy",
|
|
174
|
+
).toBeFalsy();
|
|
175
|
+
|
|
176
|
+
// Create new actor with same key using getOrCreate
|
|
177
|
+
const newActor = client.destroyActor.getOrCreate([
|
|
178
|
+
"test-destroy-with-connect",
|
|
179
|
+
]);
|
|
180
|
+
|
|
181
|
+
// Verify state is fresh (default value, not the old value)
|
|
182
|
+
const newValue = await newActor.getValue();
|
|
183
|
+
expect(newValue).toBe(0);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("actor destroy allows recreation via getOrCreate with resolve", async (c) => {
|
|
187
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
188
|
+
|
|
189
|
+
const actorKey = "test-destroy-getorcreate-resolve";
|
|
190
|
+
|
|
191
|
+
// Get destroy observer
|
|
192
|
+
const observer = client.destroyObserver.getOrCreate(["observer"]);
|
|
193
|
+
await observer.reset();
|
|
194
|
+
|
|
195
|
+
// Create actor
|
|
196
|
+
const destroyActor = client.destroyActor.getOrCreate([actorKey]);
|
|
197
|
+
|
|
198
|
+
// Update state and save immediately
|
|
199
|
+
await destroyActor.setValue(123);
|
|
200
|
+
|
|
201
|
+
// Verify state was saved
|
|
202
|
+
const value = await destroyActor.getValue();
|
|
203
|
+
expect(value).toBe(123);
|
|
204
|
+
|
|
205
|
+
// Get actor ID before destroying
|
|
206
|
+
const actorId = await destroyActor.resolve();
|
|
207
|
+
|
|
208
|
+
// Destroy the actor
|
|
209
|
+
await destroyActor.destroy();
|
|
210
|
+
|
|
211
|
+
// Wait until the observer confirms the actor was destroyed
|
|
212
|
+
await vi.waitFor(async () => {
|
|
213
|
+
const wasDestroyed = await observer.wasDestroyed(actorKey);
|
|
214
|
+
expect(wasDestroyed, "actor onDestroy not called").toBeTruthy();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Wait until the actor is fully cleaned up
|
|
218
|
+
await vi.waitFor(async () => {
|
|
219
|
+
let actorRunning = false;
|
|
220
|
+
try {
|
|
221
|
+
await client.destroyActor.getForId(actorId).getValue();
|
|
222
|
+
actorRunning = true;
|
|
223
|
+
} catch (err) {
|
|
224
|
+
expect((err as ActorError).group).toBe("actor");
|
|
225
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
expect(actorRunning, "actor still running").toBeFalsy();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// Recreate using getOrCreate with resolve
|
|
232
|
+
const newHandle = client.destroyActor.getOrCreate([actorKey]);
|
|
233
|
+
const newActorId = await newHandle.resolve();
|
|
234
|
+
|
|
235
|
+
// Verify state is fresh (default value, not the old value)
|
|
236
|
+
const newValue = await newHandle.getValue();
|
|
237
|
+
expect(newValue).toBe(0);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("actor destroy allows recreation via create", async (c) => {
|
|
241
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
242
|
+
|
|
243
|
+
const actorKey = "test-destroy-create";
|
|
244
|
+
|
|
245
|
+
// Get destroy observer
|
|
246
|
+
const observer = client.destroyObserver.getOrCreate(["observer"]);
|
|
247
|
+
await observer.reset();
|
|
248
|
+
|
|
249
|
+
// Create actor using create()
|
|
250
|
+
const initialHandle = await client.destroyActor.create([actorKey]);
|
|
251
|
+
|
|
252
|
+
// Update state and save immediately
|
|
253
|
+
await initialHandle.setValue(456);
|
|
254
|
+
|
|
255
|
+
// Verify state was saved
|
|
256
|
+
const value = await initialHandle.getValue();
|
|
257
|
+
expect(value).toBe(456);
|
|
258
|
+
|
|
259
|
+
// Get actor ID before destroying
|
|
260
|
+
const actorId = await initialHandle.resolve();
|
|
261
|
+
|
|
262
|
+
// Destroy the actor
|
|
263
|
+
await initialHandle.destroy();
|
|
264
|
+
|
|
265
|
+
// Wait until the observer confirms the actor was destroyed
|
|
266
|
+
await vi.waitFor(async () => {
|
|
267
|
+
const wasDestroyed = await observer.wasDestroyed(actorKey);
|
|
268
|
+
expect(wasDestroyed, "actor onDestroy not called").toBeTruthy();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// Wait until the actor is fully cleaned up
|
|
272
|
+
await vi.waitFor(async () => {
|
|
273
|
+
let actorRunning = false;
|
|
274
|
+
try {
|
|
275
|
+
await client.destroyActor.getForId(actorId).getValue();
|
|
276
|
+
actorRunning = true;
|
|
277
|
+
} catch (err) {
|
|
278
|
+
expect((err as ActorError).group).toBe("actor");
|
|
279
|
+
expect((err as ActorError).code).toBe("not_found");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
expect(actorRunning, "actor still running").toBeFalsy();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Recreate using create()
|
|
286
|
+
const newHandle = await client.destroyActor.create([actorKey]);
|
|
287
|
+
const newActorId = await newHandle.resolve();
|
|
288
|
+
|
|
289
|
+
// Verify state is fresh (default value, not the old value)
|
|
290
|
+
const newValue = await newHandle.getValue();
|
|
291
|
+
expect(newValue).toBe(0);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
@@ -11,14 +11,7 @@ export function runActorDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
11
11
|
|
|
12
12
|
// Run scheduled alarms tests
|
|
13
13
|
runActorScheduleTests(driverTestConfig);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
14
|
|
|
17
|
-
/** Actor driver tests that need to be tested for all transport mechanisms. */
|
|
18
|
-
export function runActorDriverTestsWithTransport(
|
|
19
|
-
driverTestConfig: DriverTestConfig,
|
|
20
|
-
) {
|
|
21
|
-
describe("Actor Driver Tests", () => {
|
|
22
15
|
// Run actor sleep tests
|
|
23
16
|
runActorSleepTests(driverTestConfig);
|
|
24
17
|
});
|
|
@@ -94,7 +94,7 @@ export function runActorHandleTests(driverTestConfig: DriverTestConfig) {
|
|
|
94
94
|
expect.fail("did not error on duplicate create");
|
|
95
95
|
} catch (err) {
|
|
96
96
|
expect((err as ActorError).group).toBe("actor");
|
|
97
|
-
expect((err as ActorError).code).toBe("
|
|
97
|
+
expect((err as ActorError).code).toBe("duplicate_key");
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -183,25 +183,25 @@ export function runActorHandleTests(driverTestConfig: DriverTestConfig) {
|
|
|
183
183
|
test("should trigger lifecycle hooks on actor creation", async (c) => {
|
|
184
184
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
185
185
|
|
|
186
|
-
// Get or create a new actor - this should trigger
|
|
186
|
+
// Get or create a new actor - this should trigger onWake
|
|
187
187
|
const handle = client.counterWithLifecycle.getOrCreate([
|
|
188
188
|
"test-lifecycle-handle",
|
|
189
189
|
]);
|
|
190
190
|
|
|
191
|
-
// Verify
|
|
191
|
+
// Verify onWake was triggered
|
|
192
192
|
const initialEvents = await handle.getEvents();
|
|
193
|
-
expect(initialEvents).toContain("
|
|
193
|
+
expect(initialEvents).toContain("onWake");
|
|
194
194
|
|
|
195
195
|
// Create a separate handle to the same actor
|
|
196
196
|
const sameHandle = client.counterWithLifecycle.getOrCreate([
|
|
197
197
|
"test-lifecycle-handle",
|
|
198
198
|
]);
|
|
199
199
|
|
|
200
|
-
// Verify events still include
|
|
201
|
-
// (
|
|
200
|
+
// Verify events still include onWake but don't duplicate it
|
|
201
|
+
// (onWake should only be called once when the actor is first created)
|
|
202
202
|
const events = await sameHandle.getEvents();
|
|
203
|
-
expect(events).toContain("
|
|
204
|
-
expect(events.filter((e) => e === "
|
|
203
|
+
expect(events).toContain("onWake");
|
|
204
|
+
expect(events.filter((e) => e === "onWake").length).toBe(1);
|
|
205
205
|
});
|
|
206
206
|
|
|
207
207
|
test("should trigger lifecycle hooks for each Action call", async (c) => {
|
|
@@ -212,9 +212,9 @@ export function runActorHandleTests(driverTestConfig: DriverTestConfig) {
|
|
|
212
212
|
"test-lifecycle-action",
|
|
213
213
|
]);
|
|
214
214
|
|
|
215
|
-
// Initial state should only have
|
|
215
|
+
// Initial state should only have onWake
|
|
216
216
|
const initialEvents = await viewHandle.getEvents();
|
|
217
|
-
expect(initialEvents).toContain("
|
|
217
|
+
expect(initialEvents).toContain("onWake");
|
|
218
218
|
expect(initialEvents).not.toContain("onBeforeConnect");
|
|
219
219
|
expect(initialEvents).not.toContain("onConnect");
|
|
220
220
|
expect(initialEvents).not.toContain("onDisconnect");
|
|
@@ -297,8 +297,8 @@ export function runActorHandleTests(driverTestConfig: DriverTestConfig) {
|
|
|
297
297
|
// Check lifecycle hooks
|
|
298
298
|
const events = await viewHandle.getEvents();
|
|
299
299
|
|
|
300
|
-
// Should have 1
|
|
301
|
-
expect(events.filter((e) => e === "
|
|
300
|
+
// Should have 1 onWake, 2 each of onBeforeConnect, onConnect, and onDisconnect
|
|
301
|
+
expect(events.filter((e) => e === "onWake").length).toBe(1);
|
|
302
302
|
expect(
|
|
303
303
|
events.filter((e) => e === "onBeforeConnect").length,
|
|
304
304
|
).toBe(2);
|
|
@@ -16,7 +16,7 @@ export function runActorMetadataTests(driverTestConfig: DriverTestConfig) {
|
|
|
16
16
|
expect(actorName).toBe("metadataActor");
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
test("should preserve actor name in state during
|
|
19
|
+
test("should preserve actor name in state during onWake", async (c) => {
|
|
20
20
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
21
21
|
|
|
22
22
|
// Get the stored actor name
|
|
@@ -43,7 +43,7 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
43
43
|
expect.fail("did not error on duplicate create");
|
|
44
44
|
} catch (err) {
|
|
45
45
|
expect((err as ActorError).group).toBe("actor");
|
|
46
|
-
expect((err as ActorError).code).toBe("
|
|
46
|
+
expect((err as ActorError).code).toBe("duplicate_key");
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Verify the original actor still works and has its state
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
//
|
|
26
26
|
// // Make a direct fetch request to the registry
|
|
27
27
|
// const response = await fetch(
|
|
28
|
-
// `${endpoint}/registry/actors/
|
|
28
|
+
// `${endpoint}/registry/actors/request/api/hello`,
|
|
29
29
|
// {
|
|
30
30
|
// method: "GET",
|
|
31
31
|
// headers: {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
//
|
|
53
53
|
// const testData = { test: "direct", number: 456 };
|
|
54
54
|
// const response = await fetch(
|
|
55
|
-
// `${endpoint}/registry/actors/
|
|
55
|
+
// `${endpoint}/registry/actors/request/api/echo`,
|
|
56
56
|
// {
|
|
57
57
|
// method: "POST",
|
|
58
58
|
// headers: {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
// };
|
|
86
86
|
//
|
|
87
87
|
// const response = await fetch(
|
|
88
|
-
// `${endpoint}/registry/actors/
|
|
88
|
+
// `${endpoint}/registry/actors/request/api/headers`,
|
|
89
89
|
// {
|
|
90
90
|
// method: "GET",
|
|
91
91
|
// headers: {
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
// const connParams = { token: "test-auth-token", userId: "user123" };
|
|
115
115
|
//
|
|
116
116
|
// const response = await fetch(
|
|
117
|
-
// `${endpoint}/registry/actors/
|
|
117
|
+
// `${endpoint}/registry/actors/request/api/hello`,
|
|
118
118
|
// {
|
|
119
119
|
// method: "GET",
|
|
120
120
|
// headers: {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
// expect(data).toEqual({ message: "Hello from actor!" });
|
|
130
130
|
// });
|
|
131
131
|
//
|
|
132
|
-
// test("should return 404 for actors without
|
|
132
|
+
// test("should return 404 for actors without onRequest handler", async (c) => {
|
|
133
133
|
// const { endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
134
134
|
//
|
|
135
135
|
// const actorQuery: ActorQuery = {
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
// };
|
|
141
141
|
//
|
|
142
142
|
// const response = await fetch(
|
|
143
|
-
// `${endpoint}/registry/actors/
|
|
143
|
+
// `${endpoint}/registry/actors/request/api/anything`,
|
|
144
144
|
// {
|
|
145
145
|
// method: "GET",
|
|
146
146
|
// headers: {
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
//
|
|
169
169
|
// for (const method of methods) {
|
|
170
170
|
// const response = await fetch(
|
|
171
|
-
// `${endpoint}/registry/actors/
|
|
171
|
+
// `${endpoint}/registry/actors/request/api/echo`,
|
|
172
172
|
// {
|
|
173
173
|
// method,
|
|
174
174
|
// headers: {
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
// // Send binary data
|
|
208
208
|
// const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
209
209
|
// const response = await fetch(
|
|
210
|
-
// `${endpoint}/registry/actors/
|
|
210
|
+
// `${endpoint}/registry/actors/request/api/echo`,
|
|
211
211
|
// {
|
|
212
212
|
// method: "POST",
|
|
213
213
|
// headers: {
|
|
@@ -8,7 +8,7 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
8
8
|
driverTestConfig: DriverTestConfig,
|
|
9
9
|
) {
|
|
10
10
|
describe("raw http request properties", () => {
|
|
11
|
-
test("should pass all Request properties correctly to
|
|
11
|
+
test("should pass all Request properties correctly to onRequest", async (c) => {
|
|
12
12
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
13
13
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
14
14
|
"test",
|
|
@@ -284,7 +284,7 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
284
284
|
expect(data.search.length).toBeGreaterThan(1000);
|
|
285
285
|
});
|
|
286
286
|
|
|
287
|
-
test("should handle large request bodies", async (c) => {
|
|
287
|
+
test.skip("should handle large request bodies", async (c) => {
|
|
288
288
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
289
289
|
const actor = client.rawHttpRequestPropertiesActor.getOrCreate([
|
|
290
290
|
"test",
|
|
@@ -341,9 +341,10 @@ export function runRawHttpRequestPropertiesTests(
|
|
|
341
341
|
});
|
|
342
342
|
|
|
343
343
|
expect(response.ok).toBe(true);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
expect(data.
|
|
344
|
+
// TODO: This is inconsistent between engine & file system driver
|
|
345
|
+
// const data = (await response.json()) as any;
|
|
346
|
+
// expect(data.body).toBeNull();
|
|
347
|
+
// expect(data.bodyText).toBe("");
|
|
347
348
|
});
|
|
348
349
|
|
|
349
350
|
test("should handle custom HTTP methods", async (c) => {
|
|
@@ -79,7 +79,7 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
79
79
|
expect(response.status).toBe(404);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
test("should return 404 when no
|
|
82
|
+
test("should return 404 when no onRequest handler defined", async (c) => {
|
|
83
83
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
84
84
|
const actor = client.rawHttpNoHandlerActor.getOrCreate([
|
|
85
85
|
"no-handler",
|
|
@@ -89,10 +89,10 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
89
89
|
expect(response.ok).toBe(false);
|
|
90
90
|
expect(response.status).toBe(404);
|
|
91
91
|
|
|
92
|
-
// No actions available without
|
|
92
|
+
// No actions available without onRequest handler
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
test("should return 500 error when
|
|
95
|
+
test("should return 500 error when onRequest returns void", async (c) => {
|
|
96
96
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
97
97
|
const actor = client.rawHttpVoidReturnActor.getOrCreate([
|
|
98
98
|
"void-return",
|
|
@@ -108,14 +108,14 @@ export function runRawHttpTests(driverTestConfig: DriverTestConfig) {
|
|
|
108
108
|
message: string;
|
|
109
109
|
};
|
|
110
110
|
expect(errorData.message).toContain(
|
|
111
|
-
"
|
|
111
|
+
"onRequest handler must return a Response",
|
|
112
112
|
);
|
|
113
113
|
} catch {
|
|
114
114
|
// If JSON parsing fails, just check that we got a 500 error
|
|
115
115
|
// The error details are already validated by the status code
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
// No actions available when
|
|
118
|
+
// No actions available when onRequest returns void
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
test("should handle different HTTP methods", async (c) => {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// const wsEndpoint = endpoint
|
|
29
29
|
// .replace(/^http:/, "ws:")
|
|
30
30
|
// .replace(/^https:/, "wss:");
|
|
31
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
31
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/`;
|
|
32
32
|
//
|
|
33
33
|
// // Create WebSocket connection with subprotocol
|
|
34
34
|
// const ws = new WebSocket(wsUrl, [
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
// const wsEndpoint = endpoint
|
|
80
80
|
// .replace(/^http:/, "ws:")
|
|
81
81
|
// .replace(/^https:/, "wss:");
|
|
82
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
82
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/`;
|
|
83
83
|
//
|
|
84
84
|
// const ws = new WebSocket(wsUrl, [
|
|
85
85
|
// queryProtocol,
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
// const wsEndpoint = endpoint
|
|
139
139
|
// .replace(/^http:/, "ws:")
|
|
140
140
|
// .replace(/^https:/, "wss:");
|
|
141
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
141
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/`;
|
|
142
142
|
//
|
|
143
143
|
// const ws = new WebSocket(wsUrl, [
|
|
144
144
|
// queryProtocol,
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
// const wsEndpoint = endpoint
|
|
192
192
|
// .replace(/^http:/, "ws:")
|
|
193
193
|
// .replace(/^https:/, "wss:");
|
|
194
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
194
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/`;
|
|
195
195
|
//
|
|
196
196
|
// const ws = new WebSocket(wsUrl, [
|
|
197
197
|
// queryProtocol,
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
// const paths = ["chat/room1", "updates/feed", "stream/events"];
|
|
248
248
|
//
|
|
249
249
|
// for (const path of paths) {
|
|
250
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
250
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/${path}`;
|
|
251
251
|
// const ws = new WebSocket(wsUrl, [
|
|
252
252
|
// queryProtocol,
|
|
253
253
|
// // HACK: See packages/drivers/cloudflare-workers/src/websocket.ts
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
// const wsEndpoint = endpoint
|
|
296
296
|
// .replace(/^http:/, "ws:")
|
|
297
297
|
// .replace(/^https:/, "wss:");
|
|
298
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
298
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/`;
|
|
299
299
|
//
|
|
300
300
|
// const ws = new WebSocket(wsUrl, [
|
|
301
301
|
// queryProtocol,
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
// const wsEndpoint = endpoint
|
|
330
330
|
// .replace(/^http:/, "ws:")
|
|
331
331
|
// .replace(/^https:/, "wss:");
|
|
332
|
-
// const wsUrl = `${wsEndpoint}/registry/actors/
|
|
332
|
+
// const wsUrl = `${wsEndpoint}/registry/actors/websocket/`;
|
|
333
333
|
//
|
|
334
334
|
// const ws = new WebSocket(wsUrl, [
|
|
335
335
|
// queryProtocol,
|
|
@@ -125,7 +125,7 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
// TODO: re-expose this once we can have actor queries on the gateway
|
|
128
|
-
// test("should have access to request object in
|
|
128
|
+
// test("should have access to request object in onRequest", async (c) => {
|
|
129
129
|
// const { client, endpoint } = await setupDriverTest(c, driverTestConfig);
|
|
130
130
|
//
|
|
131
131
|
// // Create actor
|
|
@@ -141,7 +141,7 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
141
141
|
// },
|
|
142
142
|
// };
|
|
143
143
|
//
|
|
144
|
-
// const url = `${endpoint}/registry/actors/
|
|
144
|
+
// const url = `${endpoint}/registry/actors/request/test-path`;
|
|
145
145
|
// const response = await fetch(url, {
|
|
146
146
|
// method: "POST",
|
|
147
147
|
// headers: {
|
|
@@ -163,7 +163,7 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
163
163
|
// expect(response.ok).toBe(true);
|
|
164
164
|
// const data = await response.json();
|
|
165
165
|
//
|
|
166
|
-
// // Verify request info from
|
|
166
|
+
// // Verify request info from onRequest
|
|
167
167
|
// expect((data as any).hasRequest).toBe(true);
|
|
168
168
|
// expect((data as any).requestUrl).toContain("/test-path");
|
|
169
169
|
// expect((data as any).requestMethod).toBe("POST");
|
|
@@ -200,7 +200,7 @@ export function runRequestAccessTests(driverTestConfig: DriverTestConfig) {
|
|
|
200
200
|
// .replace("http://", "ws://")
|
|
201
201
|
// .replace("https://", "wss://");
|
|
202
202
|
// const ws = new WebSocket(
|
|
203
|
-
// `${wsUrl}/registry/actors/
|
|
203
|
+
// `${wsUrl}/registry/actors/websocket/test-path`,
|
|
204
204
|
// [
|
|
205
205
|
// queryProtocol,
|
|
206
206
|
// "rivetkit", // Required protocol
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import invariant from "invariant";
|
|
2
1
|
import { type TestContext, vi } from "vitest";
|
|
3
2
|
import { assertUnreachable } from "@/actor/utils";
|
|
4
3
|
import { type Client, createClient } from "@/client/mod";
|
|
@@ -7,6 +6,7 @@ import { createClientWithDriver } from "@/mod";
|
|
|
7
6
|
import type { registry } from "../../fixtures/driver-test-suite/registry";
|
|
8
7
|
import type { DriverTestConfig } from "./mod";
|
|
9
8
|
import { createTestInlineClientDriver } from "./test-inline-client-driver";
|
|
9
|
+
import { logger } from "./log";
|
|
10
10
|
|
|
11
11
|
export const FAKE_TIME = new Date("2024-01-01T00:00:00.000Z");
|
|
12
12
|
|
|
@@ -26,7 +26,10 @@ export async function setupDriverTest(
|
|
|
26
26
|
// Build drivers
|
|
27
27
|
const { endpoint, namespace, runnerName, cleanup } =
|
|
28
28
|
await driverTestConfig.start();
|
|
29
|
-
c.onTestFinished(
|
|
29
|
+
c.onTestFinished(() => {
|
|
30
|
+
logger().info("cleaning up test");
|
|
31
|
+
cleanup();
|
|
32
|
+
});
|
|
30
33
|
|
|
31
34
|
let client: Client<typeof registry>;
|
|
32
35
|
if (driverTestConfig.clientType === "http") {
|
|
@@ -35,20 +38,13 @@ export async function setupDriverTest(
|
|
|
35
38
|
endpoint,
|
|
36
39
|
namespace,
|
|
37
40
|
runnerName,
|
|
38
|
-
transport: driverTestConfig.transport,
|
|
39
41
|
encoding: driverTestConfig.encoding,
|
|
40
42
|
});
|
|
41
43
|
} else if (driverTestConfig.clientType === "inline") {
|
|
42
44
|
// Use inline client from driver
|
|
43
|
-
const transport = driverTestConfig.transport ?? "websocket";
|
|
44
45
|
const encoding = driverTestConfig.encoding ?? "bare";
|
|
45
|
-
const managerDriver = createTestInlineClientDriver(
|
|
46
|
-
endpoint,
|
|
47
|
-
encoding,
|
|
48
|
-
transport,
|
|
49
|
-
);
|
|
46
|
+
const managerDriver = createTestInlineClientDriver(endpoint, encoding);
|
|
50
47
|
const runConfig = RunConfigSchema.parse({
|
|
51
|
-
transport: transport,
|
|
52
48
|
encoding: encoding,
|
|
53
49
|
});
|
|
54
50
|
client = createClientWithDriver(managerDriver, runConfig);
|