rivetkit 2.0.42 → 2.1.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{tsup/config-CLnylLYY.d.ts → browser/client.d.ts} +2127 -1910
- package/dist/browser/client.js +5182 -0
- package/dist/browser/client.js.map +1 -0
- package/dist/browser/inspector/client.d.ts +130 -0
- package/dist/browser/inspector/client.js +2854 -0
- package/dist/browser/inspector/client.js.map +1 -0
- package/dist/browser/v3-DnYObHH3.d.ts +279 -0
- package/dist/schemas/actor-inspector/v2.ts +796 -0
- package/dist/schemas/actor-inspector/v3.ts +899 -0
- package/dist/schemas/actor-persist/v4.ts +406 -0
- package/dist/schemas/client-protocol/v3.ts +554 -0
- package/dist/schemas/persist/v1.ts +781 -0
- package/dist/schemas/transport/v1.ts +697 -0
- package/dist/tsup/actor/errors.cjs +27 -3
- package/dist/tsup/actor/errors.cjs.map +1 -1
- package/dist/tsup/actor/errors.d.cts +37 -1
- package/dist/tsup/actor/errors.d.ts +37 -1
- package/dist/tsup/actor/errors.js +26 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.cts → actor-router-consts-D29T1Z-K.d.cts} +1 -1
- package/dist/tsup/{actor-router-consts-DzI2szci.d.ts → actor-router-consts-D29T1Z-K.d.ts} +1 -1
- package/dist/tsup/chunk-424PT5DM.js +23 -0
- package/dist/tsup/chunk-424PT5DM.js.map +1 -0
- package/dist/tsup/{chunk-JDAD2YFA.js → chunk-5ESWDTHJ.js} +148 -273
- package/dist/tsup/chunk-5ESWDTHJ.js.map +1 -0
- package/dist/tsup/{chunk-FJ3KTN4V.js → chunk-6LIBPELE.js} +119 -11
- package/dist/tsup/chunk-6LIBPELE.js.map +1 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs +96 -0
- package/dist/tsup/chunk-6LJAZ5R4.cjs.map +1 -0
- package/dist/tsup/{chunk-LFVF5SCU.js → chunk-7HTNH26M.js} +126 -1
- package/dist/tsup/chunk-7HTNH26M.js.map +1 -0
- package/dist/tsup/chunk-7K4CYDGD.js +630 -0
- package/dist/tsup/chunk-7K4CYDGD.js.map +1 -0
- package/dist/tsup/{chunk-XXGJCOL6.js → chunk-A6YIZWTK.js} +2 -2
- package/dist/tsup/chunk-AIYEYMX5.cjs +630 -0
- package/dist/tsup/chunk-AIYEYMX5.cjs.map +1 -0
- package/dist/tsup/{chunk-Q6W7RJJP.js → chunk-DIGBC2VI.js} +211 -2316
- package/dist/tsup/chunk-DIGBC2VI.js.map +1 -0
- package/dist/tsup/{chunk-RZW2DNND.cjs → chunk-F6JYU5IK.cjs} +1957 -1039
- package/dist/tsup/chunk-F6JYU5IK.cjs.map +1 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs +534 -0
- package/dist/tsup/chunk-HAZL2EPK.cjs.map +1 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs +23 -0
- package/dist/tsup/chunk-HDQ2JUQT.cjs.map +1 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs +1036 -0
- package/dist/tsup/chunk-HIDX4C5Y.cjs.map +1 -0
- package/dist/tsup/chunk-IVG73YCW.js +534 -0
- package/dist/tsup/chunk-IVG73YCW.js.map +1 -0
- package/dist/tsup/chunk-KJSYAUOM.js +96 -0
- package/dist/tsup/chunk-KJSYAUOM.js.map +1 -0
- package/dist/tsup/{chunk-2XQS746M.cjs → chunk-L47L3ZWJ.cjs} +127 -2
- package/dist/tsup/chunk-L47L3ZWJ.cjs.map +1 -0
- package/dist/tsup/{chunk-H4TB4X25.cjs → chunk-LW6KLR7A.cjs} +126 -18
- package/dist/tsup/chunk-LW6KLR7A.cjs.map +1 -0
- package/dist/tsup/chunk-LXUQ667X.js +2006 -0
- package/dist/tsup/chunk-LXUQ667X.js.map +1 -0
- package/dist/tsup/{chunk-GMAVRZSF.js → chunk-M2T62AZQ.js} +1790 -872
- package/dist/tsup/chunk-M2T62AZQ.js.map +1 -0
- package/dist/tsup/chunk-MZ37VV3P.js +5974 -0
- package/dist/tsup/chunk-MZ37VV3P.js.map +1 -0
- package/dist/tsup/chunk-N4KRDJ56.js +72 -0
- package/dist/tsup/chunk-N4KRDJ56.js.map +1 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs +2006 -0
- package/dist/tsup/chunk-NIYZDWMW.cjs.map +1 -0
- package/dist/tsup/chunk-OMEPCQK2.js +649 -0
- package/dist/tsup/chunk-OMEPCQK2.js.map +1 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs +72 -0
- package/dist/tsup/chunk-SR3KQE7Q.cjs.map +1 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs +2657 -0
- package/dist/tsup/chunk-SSEP6DHP.cjs.map +1 -0
- package/dist/tsup/chunk-T5YCUGVS.js +1036 -0
- package/dist/tsup/chunk-T5YCUGVS.js.map +1 -0
- package/dist/tsup/{chunk-EJVBH5VF.cjs → chunk-TPGXWFQT.cjs} +3 -3
- package/dist/tsup/{chunk-EJVBH5VF.cjs.map → chunk-TPGXWFQT.cjs.map} +1 -1
- package/dist/tsup/{chunk-X35U3YNX.cjs → chunk-TYLXNCA5.cjs} +214 -339
- package/dist/tsup/chunk-TYLXNCA5.cjs.map +1 -0
- package/dist/tsup/chunk-VKVNIQRQ.js +257 -0
- package/dist/tsup/chunk-VKVNIQRQ.js.map +1 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs +649 -0
- package/dist/tsup/chunk-XWBAQO5H.cjs.map +1 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs +5974 -0
- package/dist/tsup/chunk-YQ4LDVD6.cjs.map +1 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs +257 -0
- package/dist/tsup/chunk-ZFY5J2EP.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -10
- package/dist/tsup/client/mod.cjs.map +1 -1
- package/dist/tsup/client/mod.d.cts +11 -5
- package/dist/tsup/client/mod.d.ts +11 -5
- package/dist/tsup/client/mod.js +8 -8
- package/dist/tsup/common/log.cjs +4 -4
- package/dist/tsup/common/log.d.cts +2 -2
- package/dist/tsup/common/log.d.ts +2 -2
- package/dist/tsup/common/log.js +3 -2
- package/dist/tsup/common/websocket.cjs +5 -5
- package/dist/tsup/common/websocket.js +4 -3
- package/dist/tsup/config-BFqid9Gr.d.ts +2574 -0
- package/dist/tsup/config-BiNoIHRs.d.cts +80 -0
- package/dist/tsup/config-BiNoIHRs.d.ts +80 -0
- package/dist/tsup/{config-CZB2-W8x.d.cts → config-CAZphOS1.d.cts} +681 -355
- package/dist/tsup/db/drizzle/mod.cjs +49 -0
- package/dist/tsup/db/drizzle/mod.cjs.map +1 -0
- package/dist/tsup/db/drizzle/mod.d.cts +17 -0
- package/dist/tsup/db/drizzle/mod.d.ts +17 -0
- package/dist/tsup/db/drizzle/mod.js +49 -0
- package/dist/tsup/db/drizzle/mod.js.map +1 -0
- package/dist/tsup/db/mod.cjs +9 -0
- package/dist/tsup/db/mod.cjs.map +1 -0
- package/dist/tsup/db/mod.d.cts +9 -0
- package/dist/tsup/db/mod.d.ts +9 -0
- package/dist/tsup/db/mod.js +9 -0
- package/dist/tsup/db/mod.js.map +1 -0
- package/dist/tsup/{driver-D0QX9M11.d.ts → driver-Bxv62E2p.d.ts} +2 -2
- package/dist/tsup/{driver-q-zqG7fc.d.cts → driver-DYXwJR5D.d.cts} +2 -2
- package/dist/tsup/driver-helpers/mod.cjs +12 -6
- package/dist/tsup/driver-helpers/mod.cjs.map +1 -1
- package/dist/tsup/driver-helpers/mod.d.cts +12 -5
- package/dist/tsup/driver-helpers/mod.d.ts +12 -5
- package/dist/tsup/driver-helpers/mod.js +12 -5
- package/dist/tsup/driver-test-suite/mod.cjs +1370 -116
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +10 -4
- package/dist/tsup/driver-test-suite/mod.d.ts +10 -4
- package/dist/tsup/driver-test-suite/mod.js +2093 -838
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +29 -3
- package/dist/tsup/inspector/mod.cjs.map +1 -1
- package/dist/tsup/inspector/mod.d.cts +124 -3
- package/dist/tsup/inspector/mod.d.ts +124 -3
- package/dist/tsup/inspector/mod.js +72 -45
- package/dist/tsup/keys-CydblqMh.d.cts +13 -0
- package/dist/tsup/keys-CydblqMh.d.ts +13 -0
- package/dist/tsup/mod.cjs +16 -10
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +26 -14
- package/dist/tsup/mod.d.ts +26 -14
- package/dist/tsup/mod.js +20 -13
- package/dist/tsup/serve-test-suite/mod.cjs +1165 -83
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +1114 -29
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +84 -11
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +10 -5
- package/dist/tsup/test/mod.d.ts +10 -5
- package/dist/tsup/test/mod.js +85 -11
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/utils.cjs +10 -4
- package/dist/tsup/utils.cjs.map +1 -1
- package/dist/tsup/utils.d.cts +72 -2
- package/dist/tsup/utils.d.ts +72 -2
- package/dist/tsup/utils.js +9 -2
- package/dist/tsup/v3-DnYObHH3.d.cts +279 -0
- package/dist/tsup/v3-DnYObHH3.d.ts +279 -0
- package/dist/tsup/workflow/mod.cjs +16 -0
- package/dist/tsup/workflow/mod.cjs.map +1 -0
- package/dist/tsup/workflow/mod.d.cts +83 -0
- package/dist/tsup/workflow/mod.d.ts +83 -0
- package/dist/tsup/workflow/mod.js +16 -0
- package/dist/tsup/workflow/mod.js.map +1 -0
- package/package.json +62 -5
- package/src/actor/config.ts +478 -68
- package/src/actor/conn/mod.ts +68 -16
- package/src/actor/conn/state-manager.ts +2 -2
- package/src/actor/contexts/action.ts +20 -12
- package/src/actor/contexts/base/actor.ts +137 -7
- package/src/actor/contexts/base/conn-init.ts +27 -7
- package/src/actor/contexts/base/conn.ts +27 -18
- package/src/actor/contexts/before-action-response.ts +9 -2
- package/src/actor/contexts/before-connect.ts +7 -2
- package/src/actor/contexts/connect.ts +9 -2
- package/src/actor/contexts/create-conn-state.ts +7 -2
- package/src/actor/contexts/create-vars.ts +16 -3
- package/src/actor/contexts/create.ts +16 -3
- package/src/actor/contexts/destroy.ts +9 -3
- package/src/actor/contexts/disconnect.ts +10 -4
- package/src/actor/contexts/index.ts +4 -3
- package/src/actor/contexts/request.ts +23 -6
- package/src/actor/contexts/run.ts +47 -0
- package/src/actor/contexts/sleep.ts +9 -3
- package/src/actor/contexts/state-change.ts +9 -3
- package/src/actor/contexts/wake.ts +9 -3
- package/src/actor/contexts/websocket.ts +23 -6
- package/src/actor/database.ts +8 -18
- package/src/actor/definition.ts +20 -6
- package/src/actor/driver.ts +32 -3
- package/src/actor/errors.ts +127 -0
- package/src/actor/instance/connection-manager.ts +183 -80
- package/src/actor/instance/event-manager.ts +26 -15
- package/src/actor/instance/keys.ts +117 -0
- package/src/actor/instance/mod.ts +784 -174
- package/src/actor/instance/queue-manager.ts +603 -0
- package/src/actor/instance/queue.ts +287 -0
- package/src/actor/instance/schedule-manager.ts +49 -7
- package/src/actor/instance/state-manager.ts +35 -11
- package/src/actor/instance/traces-driver.ts +128 -0
- package/src/actor/mod.ts +26 -2
- package/src/actor/protocol/old.ts +28 -13
- package/src/actor/protocol/serde.ts +1 -1
- package/src/actor/router-endpoints.ts +177 -21
- package/src/actor/router-websocket-endpoints.ts +18 -29
- package/src/actor/router.ts +177 -0
- package/src/actor/schema.ts +291 -0
- package/src/actor/utils.ts +40 -0
- package/src/client/actor-common.ts +1 -1
- package/src/client/actor-conn.ts +100 -33
- package/src/client/actor-handle.ts +61 -33
- package/src/client/client.ts +2 -4
- package/src/client/config.ts +1 -1
- package/src/client/mod.browser.ts +2 -0
- package/src/client/mod.ts +1 -4
- package/src/client/queue.ts +146 -0
- package/src/client/utils.ts +1 -1
- package/src/common/log.ts +1 -1
- package/src/common/utils.ts +3 -3
- package/src/db/config.ts +100 -0
- package/src/db/drizzle/mod.ts +226 -0
- package/src/db/drizzle/sqlite-core.ts +22 -0
- package/src/db/mod.ts +125 -0
- package/src/db/shared.ts +92 -0
- package/src/db/sqlite-vfs.ts +12 -0
- package/src/driver-helpers/mod.ts +1 -0
- package/src/driver-test-suite/mod.ts +69 -43
- package/src/driver-test-suite/tests/access-control.ts +218 -0
- package/src/driver-test-suite/tests/actor-db-raw.ts +73 -0
- package/src/driver-test-suite/tests/actor-db.ts +394 -0
- package/src/driver-test-suite/tests/actor-inspector.ts +259 -358
- package/src/driver-test-suite/tests/actor-kv.ts +41 -20
- package/src/driver-test-suite/tests/actor-queue.ts +324 -0
- package/src/driver-test-suite/tests/actor-run.ts +181 -0
- package/src/driver-test-suite/tests/actor-schedule.ts +5 -2
- package/src/driver-test-suite/tests/actor-sleep.ts +3 -3
- package/src/driver-test-suite/tests/actor-stateless.ts +70 -0
- package/src/driver-test-suite/tests/actor-workflow.ts +108 -0
- package/src/driver-test-suite/tests/manager-driver.ts +11 -0
- package/src/driver-test-suite/tests/raw-http-request-properties.ts +1 -1
- package/src/driver-test-suite/tests/raw-websocket.ts +12 -12
- package/src/drivers/default.ts +7 -2
- package/src/drivers/engine/actor-driver.ts +45 -37
- package/src/drivers/engine/config.ts +1 -1
- package/src/drivers/file-system/actor.ts +20 -2
- package/src/drivers/file-system/global-state.ts +569 -258
- package/src/drivers/file-system/kv-limits.ts +70 -0
- package/src/drivers/file-system/manager.ts +22 -6
- package/src/drivers/file-system/mod.ts +39 -16
- package/src/drivers/file-system/sqlite-runtime.ts +210 -0
- package/src/inspector/actor-inspector.ts +224 -102
- package/src/inspector/config.ts +1 -1
- package/src/inspector/handler.ts +102 -20
- package/src/inspector/mod.browser.ts +8 -0
- package/src/inspector/mod.ts +2 -0
- package/src/inspector/serve-ui.ts +40 -0
- package/src/inspector/transport.ts +18 -0
- package/src/inspector/utils.ts +5 -39
- package/src/manager/gateway.ts +1 -1
- package/src/manager/protocol/mod.ts +1 -1
- package/src/manager/protocol/query.ts +1 -1
- package/src/manager/router-schema.ts +1 -1
- package/src/manager/router.ts +38 -12
- package/src/manager-api/actors.ts +1 -1
- package/src/manager-api/common.ts +1 -1
- package/src/registry/config/driver.ts +1 -1
- package/src/registry/config/index.ts +212 -43
- package/src/registry/config/legacy-runner.ts +1 -1
- package/src/registry/config/runner.ts +1 -1
- package/src/registry/config/serverless.ts +1 -1
- package/src/registry/index.ts +7 -5
- package/src/remote-manager-driver/api-utils.ts +1 -1
- package/src/schemas/actor-inspector/mod.ts +1 -1
- package/src/schemas/actor-inspector/versioned.ts +195 -8
- package/src/schemas/actor-persist/versioned.ts +87 -7
- package/src/schemas/client-protocol/mod.ts +1 -1
- package/src/schemas/client-protocol/versioned.ts +127 -11
- package/src/schemas/client-protocol-zod/mod.ts +16 -1
- package/src/schemas/persist/mod.ts +1 -0
- package/src/schemas/transport/mod.ts +1 -0
- package/src/serde.ts +1 -1
- package/src/serve-test-suite/mod.ts +10 -9
- package/src/test/mod.ts +15 -56
- package/src/utils/endpoint-parser.test.ts +1 -1
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +12 -1
- package/src/utils/node.ts +15 -2
- package/src/utils.test.ts +34 -0
- package/src/utils.ts +140 -6
- package/src/workflow/constants.ts +2 -0
- package/src/workflow/context.ts +532 -0
- package/src/workflow/driver.ts +191 -0
- package/src/workflow/inspector.ts +268 -0
- package/src/workflow/mod.ts +122 -0
- package/dist/tsup/chunk-2IJTYN6K.cjs +0 -278
- package/dist/tsup/chunk-2IJTYN6K.cjs.map +0 -1
- package/dist/tsup/chunk-2XQS746M.cjs.map +0 -1
- package/dist/tsup/chunk-3VP5CSHV.cjs +0 -114
- package/dist/tsup/chunk-3VP5CSHV.cjs.map +0 -1
- package/dist/tsup/chunk-AQFSQMBG.js +0 -114
- package/dist/tsup/chunk-AQFSQMBG.js.map +0 -1
- package/dist/tsup/chunk-E6ZE2YEA.js +0 -664
- package/dist/tsup/chunk-E6ZE2YEA.js.map +0 -1
- package/dist/tsup/chunk-FJ3KTN4V.js.map +0 -1
- package/dist/tsup/chunk-GBENOENJ.cjs +0 -8
- package/dist/tsup/chunk-GBENOENJ.cjs.map +0 -1
- package/dist/tsup/chunk-GD7UXGOE.cjs +0 -4762
- package/dist/tsup/chunk-GD7UXGOE.cjs.map +0 -1
- package/dist/tsup/chunk-GMAVRZSF.js.map +0 -1
- package/dist/tsup/chunk-H4TB4X25.cjs.map +0 -1
- package/dist/tsup/chunk-JDAD2YFA.js.map +0 -1
- package/dist/tsup/chunk-KCOVZOPS.js +0 -1946
- package/dist/tsup/chunk-KCOVZOPS.js.map +0 -1
- package/dist/tsup/chunk-KDFWJKMJ.cjs +0 -664
- package/dist/tsup/chunk-KDFWJKMJ.cjs.map +0 -1
- package/dist/tsup/chunk-LFVF5SCU.js.map +0 -1
- package/dist/tsup/chunk-Q6W7RJJP.js.map +0 -1
- package/dist/tsup/chunk-RUW5CZ5Z.cjs +0 -1949
- package/dist/tsup/chunk-RUW5CZ5Z.cjs.map +0 -1
- package/dist/tsup/chunk-RZW2DNND.cjs.map +0 -1
- package/dist/tsup/chunk-TCOEBUUE.js +0 -278
- package/dist/tsup/chunk-TCOEBUUE.js.map +0 -1
- package/dist/tsup/chunk-X35U3YNX.cjs.map +0 -1
- package/dist/tsup/keys-Chhy4ylv.d.cts +0 -8
- package/dist/tsup/keys-Chhy4ylv.d.ts +0 -8
- package/dist/tsup/v1-Gq4avTK3.d.cts +0 -240
- package/dist/tsup/v1-Gq4avTK3.d.ts +0 -240
- /package/dist/tsup/{chunk-XXGJCOL6.js.map → chunk-A6YIZWTK.js.map} +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
WORKFLOW_QUEUE_NAME,
|
|
4
|
+
} from "../../../fixtures/driver-test-suite/workflow";
|
|
5
|
+
import type { DriverTestConfig } from "../mod";
|
|
6
|
+
import { setupDriverTest, waitFor } from "../utils";
|
|
7
|
+
|
|
8
|
+
export function runActorWorkflowTests(driverTestConfig: DriverTestConfig) {
|
|
9
|
+
describe("Actor Workflow Tests", () => {
|
|
10
|
+
test("replays steps and guards state access", async (c) => {
|
|
11
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
12
|
+
const actor = client.workflowCounterActor.getOrCreate([
|
|
13
|
+
"workflow-basic",
|
|
14
|
+
]);
|
|
15
|
+
|
|
16
|
+
await waitFor(driverTestConfig, 1000);
|
|
17
|
+
const state = await actor.getState();
|
|
18
|
+
expect(state.runCount).toBeGreaterThan(0);
|
|
19
|
+
expect(state.history.length).toBeGreaterThan(0);
|
|
20
|
+
expect(state.guardTriggered).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("consumes queue messages via workflow queue.next", async (c) => {
|
|
24
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
25
|
+
const actor = client.workflowQueueActor.getOrCreate(["workflow-queue"]);
|
|
26
|
+
|
|
27
|
+
await actor.send(WORKFLOW_QUEUE_NAME, {
|
|
28
|
+
hello: "world",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
await waitFor(driverTestConfig, 200);
|
|
32
|
+
const messages = await actor.getMessages();
|
|
33
|
+
expect(messages).toEqual([{ hello: "world" }]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("workflow queue.next supports completing wait sends", async (c) => {
|
|
37
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
38
|
+
const actor = client.workflowQueueActor.getOrCreate([
|
|
39
|
+
"workflow-queue-wait",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const result = await actor.sendAndWait({ value: 123 });
|
|
43
|
+
expect(result).toEqual({
|
|
44
|
+
status: "completed",
|
|
45
|
+
response: { echo: { value: 123 } },
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("db and client are step-only in workflow context", async (c) => {
|
|
50
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
51
|
+
const actor = client.workflowAccessActor.getOrCreate([
|
|
52
|
+
"workflow-access",
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
let state = await actor.getState();
|
|
56
|
+
for (let i = 0; i < 20 && state.insideDbCount === 0; i++) {
|
|
57
|
+
await waitFor(driverTestConfig, 50);
|
|
58
|
+
state = await actor.getState();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
expect(state.outsideDbError).toBe(
|
|
62
|
+
"db is only available inside workflow steps",
|
|
63
|
+
);
|
|
64
|
+
expect(state.outsideClientError).toBe(
|
|
65
|
+
"client is only available inside workflow steps",
|
|
66
|
+
);
|
|
67
|
+
expect(state.insideDbCount).toBeGreaterThan(0);
|
|
68
|
+
expect(state.insideClientAvailable).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("sleeps and resumes between ticks", async (c) => {
|
|
72
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
73
|
+
const actor = client.workflowSleepActor.getOrCreate(["workflow-sleep"]);
|
|
74
|
+
|
|
75
|
+
const initial = await actor.getState();
|
|
76
|
+
await waitFor(driverTestConfig, 200);
|
|
77
|
+
const next = await actor.getState();
|
|
78
|
+
|
|
79
|
+
expect(next.ticks).toBeGreaterThan(initial.ticks);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test.skipIf(driverTestConfig.skip?.sleep)(
|
|
83
|
+
"workflow run teardown does not wait for runStopTimeout",
|
|
84
|
+
async (c) => {
|
|
85
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
86
|
+
const actor = client.workflowStopTeardownActor.getOrCreate([
|
|
87
|
+
"workflow-stop-teardown",
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
await actor.getTimeline();
|
|
91
|
+
await waitFor(driverTestConfig, 1_200);
|
|
92
|
+
const timeline = await actor.getTimeline();
|
|
93
|
+
|
|
94
|
+
expect(timeline.wakeAts.length).toBeGreaterThanOrEqual(2);
|
|
95
|
+
expect(timeline.sleepAts.length).toBeGreaterThanOrEqual(1);
|
|
96
|
+
|
|
97
|
+
const firstSleepDelayMs =
|
|
98
|
+
timeline.sleepAts[0] - timeline.wakeAts[0];
|
|
99
|
+
expect(firstSleepDelayMs).toBeLessThan(1_800);
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// NOTE: Test for workflow persistence across actor sleep is complex because
|
|
104
|
+
// calling c.sleep() during a workflow prevents clean shutdown. The workflow
|
|
105
|
+
// persistence is implicitly tested by the "sleeps and resumes between ticks"
|
|
106
|
+
// test which verifies the workflow continues from persisted state.
|
|
107
|
+
});
|
|
108
|
+
}
|
|
@@ -224,6 +224,17 @@ export function runManagerDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
describe("Key Matching", () => {
|
|
227
|
+
test("multi-part actor keys are passed through correctly", async (c) => {
|
|
228
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
229
|
+
|
|
230
|
+
// Create an actor with a multi-part key
|
|
231
|
+
const multiPartKey = ["tenant/with/slash", "room"];
|
|
232
|
+
const counter = client.counter.getOrCreate(multiPartKey);
|
|
233
|
+
|
|
234
|
+
// Should be preserved as a multi-part key (["tenant/with/slash", "room"])
|
|
235
|
+
expect(await counter.getKey()).toEqual(multiPartKey);
|
|
236
|
+
});
|
|
237
|
+
|
|
227
238
|
test("matches actors only with exactly the same keys", async (c) => {
|
|
228
239
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
229
240
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
3
|
import { registry } from "../../../fixtures/driver-test-suite/registry";
|
|
4
4
|
import type { DriverTestConfig } from "../mod";
|
|
5
5
|
import { setupDriverTest } from "../utils";
|
|
@@ -8,7 +8,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
8
8
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
9
9
|
const actor = client.rawWebSocketActor.getOrCreate(["basic"]);
|
|
10
10
|
|
|
11
|
-
const ws = await actor.
|
|
11
|
+
const ws = await actor.webSocket();
|
|
12
12
|
|
|
13
13
|
// The WebSocket should already be open since openWebSocket waits for openPromise
|
|
14
14
|
// But we still need to ensure any buffered events are processed
|
|
@@ -50,7 +50,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
50
50
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
51
51
|
const actor = client.rawWebSocketActor.getOrCreate(["echo"]);
|
|
52
52
|
|
|
53
|
-
const ws = await actor.
|
|
53
|
+
const ws = await actor.webSocket();
|
|
54
54
|
|
|
55
55
|
// Check if WebSocket is already open
|
|
56
56
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
@@ -92,7 +92,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
92
92
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
93
93
|
const actor = client.rawWebSocketActor.getOrCreate(["ping"]);
|
|
94
94
|
|
|
95
|
-
const ws = await actor.
|
|
95
|
+
const ws = await actor.webSocket();
|
|
96
96
|
|
|
97
97
|
// Check if WebSocket is already open
|
|
98
98
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
@@ -134,7 +134,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
134
134
|
const actor1 = client.rawWebSocketActor.getOrCreate(["stats"]);
|
|
135
135
|
|
|
136
136
|
// Create first connection to ensure actor exists
|
|
137
|
-
const ws1 = await actor1.
|
|
137
|
+
const ws1 = await actor1.webSocket();
|
|
138
138
|
const ws1MessagePromise = new Promise<void>((resolve, reject) => {
|
|
139
139
|
ws1.addEventListener("message", () => resolve(), {
|
|
140
140
|
once: true,
|
|
@@ -147,7 +147,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
147
147
|
|
|
148
148
|
// Now get reference to same actor
|
|
149
149
|
const actor2 = client.rawWebSocketActor.get(["stats"]);
|
|
150
|
-
const ws2 = await actor2.
|
|
150
|
+
const ws2 = await actor2.webSocket();
|
|
151
151
|
const ws2MessagePromise = new Promise<void>((resolve, reject) => {
|
|
152
152
|
ws2.addEventListener("message", () => resolve(), {
|
|
153
153
|
once: true,
|
|
@@ -203,7 +203,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
203
203
|
"binary",
|
|
204
204
|
]);
|
|
205
205
|
|
|
206
|
-
const ws = await actor.
|
|
206
|
+
const ws = await actor.webSocket();
|
|
207
207
|
|
|
208
208
|
// Check if WebSocket is already open
|
|
209
209
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
@@ -267,7 +267,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
267
267
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
268
268
|
const actor = client.rawWebSocketActor.getOrCreate(["paths"]);
|
|
269
269
|
|
|
270
|
-
const ws = await actor.
|
|
270
|
+
const ws = await actor.webSocket("custom/path");
|
|
271
271
|
|
|
272
272
|
await new Promise<void>((resolve, reject) => {
|
|
273
273
|
ws.addEventListener("open", () => {
|
|
@@ -297,7 +297,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
297
297
|
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
298
298
|
const actor = client.rawWebSocketActor.getOrCreate(["close-test"]);
|
|
299
299
|
|
|
300
|
-
const ws = await actor.
|
|
300
|
+
const ws = await actor.webSocket();
|
|
301
301
|
|
|
302
302
|
// Check if WebSocket is already open
|
|
303
303
|
if (ws.readyState !== WebSocket.OPEN) {
|
|
@@ -343,7 +343,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
343
343
|
]);
|
|
344
344
|
|
|
345
345
|
// Create first connection
|
|
346
|
-
const ws1 = await actor.
|
|
346
|
+
const ws1 = await actor.webSocket();
|
|
347
347
|
|
|
348
348
|
// Wait for open event
|
|
349
349
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -367,7 +367,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
367
367
|
expect(welcome1.connectionCount).toBe(1);
|
|
368
368
|
|
|
369
369
|
// Create second connection to same actor
|
|
370
|
-
const ws2 = await actor.
|
|
370
|
+
const ws2 = await actor.webSocket();
|
|
371
371
|
|
|
372
372
|
await new Promise<void>((resolve, reject) => {
|
|
373
373
|
ws2.addEventListener("open", () => resolve(), { once: true });
|
|
@@ -438,7 +438,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
438
438
|
]);
|
|
439
439
|
|
|
440
440
|
// Test WebSocket with query parameters
|
|
441
|
-
const ws = await actor.
|
|
441
|
+
const ws = await actor.webSocket(
|
|
442
442
|
"api/v1/stream?token=abc123&user=test",
|
|
443
443
|
);
|
|
444
444
|
|
|
@@ -478,7 +478,7 @@ export function runRawWebSocketTests(driverTestConfig: DriverTestConfig) {
|
|
|
478
478
|
|
|
479
479
|
// Test WebSocket with ONLY query parameters on the base path
|
|
480
480
|
// This tests the case where path is "/websocket?foo=bar" without trailing slash
|
|
481
|
-
const ws = await actor.
|
|
481
|
+
const ws = await actor.webSocket("?token=secret&session=123");
|
|
482
482
|
|
|
483
483
|
await new Promise<void>((resolve, reject) => {
|
|
484
484
|
ws.addEventListener("open", () => resolve(), { once: true });
|
package/src/drivers/default.ts
CHANGED
|
@@ -28,6 +28,11 @@ export function chooseDefaultDriver(
|
|
|
28
28
|
return createEngineDriver();
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
loggerWithoutContext().debug({
|
|
32
|
-
|
|
31
|
+
loggerWithoutContext().debug({
|
|
32
|
+
msg: "using default file system driver",
|
|
33
|
+
storagePath: config.storagePath,
|
|
34
|
+
});
|
|
35
|
+
return createFileSystemOrMemoryDriver(true, {
|
|
36
|
+
path: config.storagePath,
|
|
37
|
+
});
|
|
33
38
|
}
|
|
@@ -82,8 +82,8 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
82
82
|
#actors: Map<string, ActorHandler> = new Map();
|
|
83
83
|
#actorRouter: ActorRouter;
|
|
84
84
|
|
|
85
|
-
#runnerStarted: PromiseWithResolvers<undefined> = promiseWithResolvers();
|
|
86
|
-
#runnerStopped: PromiseWithResolvers<undefined> = promiseWithResolvers();
|
|
85
|
+
#runnerStarted: PromiseWithResolvers<undefined> = promiseWithResolvers((reason) => logger().warn({ msg: "unhandled runner started promise rejection", reason }));
|
|
86
|
+
#runnerStopped: PromiseWithResolvers<undefined> = promiseWithResolvers((reason) => logger().warn({ msg: "unhandled runner stopped promise rejection", reason }));
|
|
87
87
|
#isRunnerStopped: boolean = false;
|
|
88
88
|
|
|
89
89
|
// HACK: Track actor stop intent locally since the runner protocol doesn't
|
|
@@ -232,9 +232,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
232
232
|
this.#runner.setAlarm(actor.id, timestamp);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
return undefined;
|
|
237
|
-
}
|
|
235
|
+
// No database overrides - will use KV-backed implementation from rivetkit/db
|
|
238
236
|
|
|
239
237
|
// MARK: - Batch KV operations
|
|
240
238
|
async kvBatchPut(
|
|
@@ -428,7 +426,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
428
426
|
// async operations to avoid race conditions where multiple calls might try to
|
|
429
427
|
// create the same handler simultaneously.
|
|
430
428
|
handler = {
|
|
431
|
-
actorStartPromise: promiseWithResolvers(),
|
|
429
|
+
actorStartPromise: promiseWithResolvers((reason) => logger().warn({ msg: "unhandled actor start promise rejection", reason })),
|
|
432
430
|
};
|
|
433
431
|
this.#actors.set(actorId, handler);
|
|
434
432
|
}
|
|
@@ -437,40 +435,50 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
437
435
|
invariant(actorConfig.key, "actor should have a key");
|
|
438
436
|
const key = deserializeActorKey(actorConfig.key);
|
|
439
437
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
438
|
+
try {
|
|
439
|
+
// Initialize storage
|
|
440
|
+
const [persistDataBuffer] = await this.#runner.kvGet(actorId, [
|
|
441
|
+
KEYS.PERSIST_DATA,
|
|
442
|
+
]);
|
|
443
|
+
if (persistDataBuffer === null) {
|
|
444
|
+
const initialKvState = getInitialActorKvState(input);
|
|
445
|
+
await this.#runner.kvPut(actorId, initialKvState);
|
|
446
|
+
logger().debug({
|
|
447
|
+
msg: "initialized persist data for new actor",
|
|
448
|
+
actorId,
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
logger().debug({
|
|
452
|
+
msg: "found existing persist data for actor",
|
|
453
|
+
actorId,
|
|
454
|
+
dataSize: persistDataBuffer.byteLength,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
458
457
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
458
|
+
// Create actor instance
|
|
459
|
+
const definition = lookupInRegistry(this.#config, actorConfig.name);
|
|
460
|
+
handler.actor = await definition.instantiate();
|
|
462
461
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
462
|
+
// Start actor
|
|
463
|
+
await handler.actor.start(
|
|
464
|
+
this,
|
|
465
|
+
this.#inlineClient,
|
|
466
|
+
actorId,
|
|
467
|
+
name,
|
|
468
|
+
key,
|
|
469
|
+
"unknown", // TODO: Add regions
|
|
470
|
+
);
|
|
472
471
|
|
|
473
|
-
|
|
472
|
+
logger().debug({ msg: "runner actor started", actorId, name, key });
|
|
473
|
+
} catch (innerError) {
|
|
474
|
+
const error = new Error(
|
|
475
|
+
`Failed to start actor ${actorId}: ${innerError}`,
|
|
476
|
+
{ cause: innerError },
|
|
477
|
+
);
|
|
478
|
+
handler.actorStartPromise?.reject(error);
|
|
479
|
+
handler.actorStartPromise = undefined;
|
|
480
|
+
throw error;
|
|
481
|
+
}
|
|
474
482
|
}
|
|
475
483
|
|
|
476
484
|
async #runnerOnActorStop(
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AnyClient } from "@/client/client";
|
|
2
|
+
import type { RawDatabaseClient } from "@/db/config";
|
|
3
|
+
import type { SqliteVfs } from "@rivetkit/sqlite-vfs";
|
|
2
4
|
import type {
|
|
3
5
|
ActorDriver,
|
|
4
6
|
AnyActorInstance,
|
|
@@ -79,8 +81,20 @@ export class FileSystemActorDriver implements ActorDriver {
|
|
|
79
81
|
await this.#state.setActorAlarm(actor.id, timestamp);
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
/** Creates a SQLite VFS instance for creating KV-backed databases */
|
|
85
|
+
async createSqliteVfs(): Promise<SqliteVfs> {
|
|
86
|
+
// Dynamic import keeps @rivetkit/sqlite out of the main entrypoint bundle,
|
|
87
|
+
// preserving tree-shakeability for environments that don't use SQLite.
|
|
88
|
+
// The async @rivetkit/sqlite build is not re-entrant per module instance.
|
|
89
|
+
// Returning a fresh SqliteVfs here gives each actor its own module,
|
|
90
|
+
// allowing actor-level parallelism without cross-actor re-entry.
|
|
91
|
+
//
|
|
92
|
+
// The specifier is built via concatenation so that bundlers like
|
|
93
|
+
// wrangler's esbuild cannot statically analyze and attempt to
|
|
94
|
+
// bundle the module (it is never used on Cloudflare Workers).
|
|
95
|
+
const specifier = "@rivetkit/" + "sqlite-vfs";
|
|
96
|
+
const { SqliteVfs } = await import(specifier);
|
|
97
|
+
return new SqliteVfs();
|
|
84
98
|
}
|
|
85
99
|
|
|
86
100
|
startSleep(actorId: string): void {
|
|
@@ -91,4 +105,8 @@ export class FileSystemActorDriver implements ActorDriver {
|
|
|
91
105
|
async startDestroy(actorId: string): Promise<void> {
|
|
92
106
|
await this.#state.destroyActor(actorId);
|
|
93
107
|
}
|
|
108
|
+
|
|
109
|
+
async onBeforeActorStart(actor: AnyActorInstance): Promise<void> {
|
|
110
|
+
await actor.cleanupPersistedConnections("file-system-driver.start");
|
|
111
|
+
}
|
|
94
112
|
}
|