rivetkit 2.1.3 → 2.1.5
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/browser/client.d.ts +11 -0
- package/dist/browser/client.js +1 -1
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/inspector.tar.gz +0 -0
- package/dist/tsup/{chunk-OAOF23ZY.js → chunk-2OK7S6QF.js} +2 -2
- package/dist/tsup/{chunk-5AZ6UPEF.cjs → chunk-7WF2QSIC.cjs} +24 -20
- package/dist/tsup/chunk-7WF2QSIC.cjs.map +1 -0
- package/dist/tsup/{chunk-IJAGZS57.cjs → chunk-D2SPAJVT.cjs} +30 -30
- package/dist/tsup/{chunk-IJAGZS57.cjs.map → chunk-D2SPAJVT.cjs.map} +1 -1
- package/dist/tsup/{chunk-YET3IZD6.js → chunk-EIATSBYZ.js} +2 -2
- package/dist/tsup/{chunk-YET3IZD6.js.map → chunk-EIATSBYZ.js.map} +1 -1
- package/dist/tsup/{chunk-DADGS67O.cjs → chunk-GQGRQDRL.cjs} +4 -4
- package/dist/tsup/{chunk-DADGS67O.cjs.map → chunk-GQGRQDRL.cjs.map} +1 -1
- package/dist/tsup/{chunk-ZSJ2OTY4.cjs → chunk-HYPIHCDT.cjs} +2 -2
- package/dist/tsup/{chunk-ZSJ2OTY4.cjs.map → chunk-HYPIHCDT.cjs.map} +1 -1
- package/dist/tsup/{chunk-HPAX7L72.cjs → chunk-IIJNPVPQ.cjs} +152 -152
- package/dist/tsup/{chunk-HPAX7L72.cjs.map → chunk-IIJNPVPQ.cjs.map} +1 -1
- package/dist/tsup/{chunk-U6VWVHVW.cjs → chunk-JC6BEPE7.cjs} +3 -3
- package/dist/tsup/{chunk-U6VWVHVW.cjs.map → chunk-JC6BEPE7.cjs.map} +1 -1
- package/dist/tsup/{chunk-N7ASEZ2Y.js → chunk-JPXO2H55.js} +5 -5
- package/dist/tsup/{chunk-QUDLEWGD.js → chunk-MIX2KB6U.js} +212 -47
- package/dist/tsup/chunk-MIX2KB6U.js.map +1 -0
- package/dist/tsup/{chunk-BMNB6YRQ.cjs → chunk-OAXJWGMU.cjs} +212 -305
- package/dist/tsup/chunk-OAXJWGMU.cjs.map +1 -0
- package/dist/tsup/{chunk-KSZZRTOD.cjs → chunk-PB5AEMKQ.cjs} +3 -5
- package/dist/tsup/chunk-PB5AEMKQ.cjs.map +1 -0
- package/dist/tsup/{chunk-6T3WSP5M.js → chunk-R5OQUSLN.js} +4 -4
- package/dist/tsup/{chunk-POUBQA6Z.js → chunk-S662Y6ZU.js} +2 -2
- package/dist/tsup/{chunk-GNGRMP5E.js → chunk-SRIM3GHD.js} +18 -11
- package/dist/tsup/chunk-SRIM3GHD.js.map +1 -0
- package/dist/tsup/{chunk-MAXIXG56.js → chunk-TADUYCHF.js} +2 -4
- package/dist/tsup/chunk-TADUYCHF.js.map +1 -0
- package/dist/tsup/{chunk-R64EFI6F.cjs → chunk-TI5PXQGG.cjs} +280 -115
- package/dist/tsup/chunk-TI5PXQGG.cjs.map +1 -0
- package/dist/tsup/{chunk-T6MM5RTW.cjs → chunk-U5SMSA27.cjs} +250 -243
- package/dist/tsup/chunk-U5SMSA27.cjs.map +1 -0
- package/dist/tsup/{chunk-6LHZQSWJ.js → chunk-WY2SHWXQ.js} +8 -4
- package/dist/tsup/chunk-WY2SHWXQ.js.map +1 -0
- package/dist/tsup/{chunk-YLDDENCZ.js → chunk-ZPWOYQHN.js} +126 -219
- package/dist/tsup/chunk-ZPWOYQHN.js.map +1 -0
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-P3XujgRr.d.ts → config-Qj-zLJPc.d.ts} +11 -0
- package/dist/tsup/{config-_gfywqqI.d.cts → config-iPj5l1bL.d.cts} +11 -0
- package/dist/tsup/{context-uNA4TRn3.d.ts → context-CQCMuHND.d.ts} +1 -1
- package/dist/tsup/{context-Bxd8Cx4H.d.cts → context-DzvH1PBK.d.cts} +1 -1
- package/dist/tsup/{driver-CPGHKXyh.d.ts → driver-Jo8v-kbU.d.ts} +1 -1
- package/dist/tsup/driver-helpers/mod.cjs +4 -4
- package/dist/tsup/driver-helpers/mod.d.cts +4 -4
- package/dist/tsup/driver-helpers/mod.d.ts +4 -4
- package/dist/tsup/driver-helpers/mod.js +3 -3
- package/dist/tsup/{driver-BcLvZcKl.d.cts → driver-iV8J-WMv.d.cts} +1 -1
- package/dist/tsup/driver-test-suite/mod.cjs +196 -60
- package/dist/tsup/driver-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/driver-test-suite/mod.d.cts +2 -2
- package/dist/tsup/driver-test-suite/mod.d.ts +2 -2
- package/dist/tsup/driver-test-suite/mod.js +971 -835
- package/dist/tsup/driver-test-suite/mod.js.map +1 -1
- package/dist/tsup/inspector/mod.cjs +3 -3
- package/dist/tsup/inspector/mod.js +2 -2
- package/dist/tsup/mod.cjs +8 -8
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +7 -7
- package/dist/tsup/serve-test-suite/mod.cjs +182 -100
- package/dist/tsup/serve-test-suite/mod.cjs.map +1 -1
- package/dist/tsup/serve-test-suite/mod.js +93 -11
- package/dist/tsup/serve-test-suite/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +10 -10
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +6 -6
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +5 -5
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +6 -6
- package/src/actor/config.ts +0 -2
- package/src/actor/instance/mod.ts +17 -4
- package/src/actor/router.ts +9 -6
- package/src/driver-test-suite/mod.ts +3 -0
- package/src/driver-test-suite/tests/actor-driver.ts +4 -0
- package/src/driver-test-suite/tests/actor-lifecycle.ts +157 -0
- package/src/driver-test-suite/tests/conn-error-serialization.ts +64 -0
- package/src/drivers/engine/actor-driver.ts +47 -15
- package/src/manager/router.ts +20 -6
- package/src/{registry → utils}/serve.ts +38 -4
- package/src/workflow/context.ts +4 -0
- package/dist/tsup/chunk-5AZ6UPEF.cjs.map +0 -1
- package/dist/tsup/chunk-6LHZQSWJ.js.map +0 -1
- package/dist/tsup/chunk-BMNB6YRQ.cjs.map +0 -1
- package/dist/tsup/chunk-GNGRMP5E.js.map +0 -1
- package/dist/tsup/chunk-KSZZRTOD.cjs.map +0 -1
- package/dist/tsup/chunk-MAXIXG56.js.map +0 -1
- package/dist/tsup/chunk-QUDLEWGD.js.map +0 -1
- package/dist/tsup/chunk-R64EFI6F.cjs.map +0 -1
- package/dist/tsup/chunk-T6MM5RTW.cjs.map +0 -1
- package/dist/tsup/chunk-YLDDENCZ.js.map +0 -1
- /package/dist/tsup/{chunk-OAOF23ZY.js.map → chunk-2OK7S6QF.js.map} +0 -0
- /package/dist/tsup/{chunk-N7ASEZ2Y.js.map → chunk-JPXO2H55.js.map} +0 -0
- /package/dist/tsup/{chunk-6T3WSP5M.js.map → chunk-R5OQUSLN.js.map} +0 -0
- /package/dist/tsup/{chunk-POUBQA6Z.js.map → chunk-S662Y6ZU.js.map} +0 -0
package/dist/tsup/test/mod.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkU5SMSA27cjs = require('../chunk-U5SMSA27.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('../chunk-
|
|
6
|
+
var _chunkIIJNPVPQcjs = require('../chunk-IIJNPVPQ.cjs');
|
|
7
|
+
require('../chunk-JC6BEPE7.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkTI5PXQGGcjs = require('../chunk-TI5PXQGG.cjs');
|
|
11
11
|
require('../chunk-NIYZDWMW.cjs');
|
|
12
|
-
require('../chunk-
|
|
12
|
+
require('../chunk-PB5AEMKQ.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkHYPIHCDTcjs = require('../chunk-HYPIHCDT.cjs');
|
|
16
16
|
require('../chunk-L47L3ZWJ.cjs');
|
|
17
17
|
require('../chunk-HDQ2JUQT.cjs');
|
|
18
18
|
|
|
@@ -23,14 +23,14 @@ var _invariant = require('invariant'); var _invariant2 = _interopRequireDefault(
|
|
|
23
23
|
|
|
24
24
|
// src/test/log.ts
|
|
25
25
|
function logger() {
|
|
26
|
-
return
|
|
26
|
+
return _chunkHYPIHCDTcjs.getLogger.call(void 0, "test");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// src/test/mod.ts
|
|
30
30
|
async function setupTest(c, registry) {
|
|
31
31
|
var _a;
|
|
32
32
|
registry.config.test = { ...registry.config.test, enabled: true };
|
|
33
|
-
const driver =
|
|
33
|
+
const driver = _chunkU5SMSA27cjs.createFileSystemOrMemoryDriver.call(void 0,
|
|
34
34
|
true,
|
|
35
35
|
{ path: `/tmp/rivetkit-test-${crypto.randomUUID()}` }
|
|
36
36
|
);
|
|
@@ -45,7 +45,7 @@ async function setupTest(c, registry) {
|
|
|
45
45
|
_invariant2.default.call(void 0, managerDriver, "missing manager driver");
|
|
46
46
|
const getUpgradeWebSocket = () => upgradeWebSocket;
|
|
47
47
|
managerDriver.setGetUpgradeWebSocket(getUpgradeWebSocket);
|
|
48
|
-
const { router } =
|
|
48
|
+
const { router } = _chunkTI5PXQGGcjs.buildManagerRouter.call(void 0,
|
|
49
49
|
parsedConfig,
|
|
50
50
|
managerDriver,
|
|
51
51
|
getUpgradeWebSocket
|
|
@@ -75,7 +75,7 @@ async function setupTest(c, registry) {
|
|
|
75
75
|
c.onTestFinished(async () => {
|
|
76
76
|
await new Promise((resolve) => server.close(() => resolve(void 0)));
|
|
77
77
|
});
|
|
78
|
-
const client =
|
|
78
|
+
const client = _chunkIIJNPVPQcjs.createClient.call(void 0, {
|
|
79
79
|
endpoint,
|
|
80
80
|
namespace: "default",
|
|
81
81
|
runnerName: "default",
|
package/dist/tsup/test/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import { a5 as Registry, C as Client } from '../config-
|
|
2
|
+
import { a5 as Registry, C as Client } from '../config-iPj5l1bL.cjs';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '@rivetkit/virtual-websocket';
|
|
5
5
|
import '../config-BiNoIHRs.cjs';
|
package/dist/tsup/test/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import { a5 as Registry, C as Client } from '../config-
|
|
2
|
+
import { a5 as Registry, C as Client } from '../config-Qj-zLJPc.js';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '@rivetkit/virtual-websocket';
|
|
5
5
|
import '../config-BiNoIHRs.js';
|
package/dist/tsup/test/mod.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createFileSystemOrMemoryDriver
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-SRIM3GHD.js";
|
|
4
4
|
import {
|
|
5
5
|
createClient
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-JPXO2H55.js";
|
|
7
|
+
import "../chunk-2OK7S6QF.js";
|
|
8
8
|
import {
|
|
9
9
|
buildManagerRouter
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-MIX2KB6U.js";
|
|
11
11
|
import "../chunk-LXUQ667X.js";
|
|
12
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-TADUYCHF.js";
|
|
13
13
|
import {
|
|
14
14
|
getLogger
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-EIATSBYZ.js";
|
|
16
16
|
import "../chunk-7HTNH26M.js";
|
|
17
17
|
import "../chunk-424PT5DM.js";
|
|
18
18
|
|
package/dist/tsup/utils.cjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkHYPIHCDTcjs = require('./chunk-HYPIHCDT.cjs');
|
|
21
21
|
require('./chunk-L47L3ZWJ.cjs');
|
|
22
22
|
require('./chunk-HDQ2JUQT.cjs');
|
|
23
23
|
|
|
@@ -39,5 +39,5 @@ require('./chunk-HDQ2JUQT.cjs');
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
exports.EXTRA_ERROR_LOG =
|
|
42
|
+
exports.EXTRA_ERROR_LOG = _chunkHYPIHCDTcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkHYPIHCDTcjs.SinglePromiseQueue; exports.VERSION = _chunkHYPIHCDTcjs.VERSION; exports.arrayBuffersEqual = _chunkHYPIHCDTcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkHYPIHCDTcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkHYPIHCDTcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkHYPIHCDTcjs.combineUrlPath; exports.dbg = _chunkHYPIHCDTcjs.dbg; exports.detectRuntime = _chunkHYPIHCDTcjs.detectRuntime; exports.getEnvUniversal = _chunkHYPIHCDTcjs.getEnvUniversal; exports.httpUserAgent = _chunkHYPIHCDTcjs.httpUserAgent; exports.interval = _chunkHYPIHCDTcjs.interval; exports.joinSignals = _chunkHYPIHCDTcjs.joinSignals; exports.promiseWithResolvers = _chunkHYPIHCDTcjs.promiseWithResolvers; exports.setLongTimeout = _chunkHYPIHCDTcjs.setLongTimeout; exports.sleep = _chunkHYPIHCDTcjs.sleep; exports.stringifyError = _chunkHYPIHCDTcjs.stringifyError; exports.toUint8Array = _chunkHYPIHCDTcjs.toUint8Array;
|
|
43
43
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/tsup/utils.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
5
|
+
var _chunk7WF2QSICcjs = require('../chunk-7WF2QSIC.cjs');
|
|
6
|
+
require('../chunk-GQGRQDRL.cjs');
|
|
7
|
+
require('../chunk-PB5AEMKQ.cjs');
|
|
8
|
+
require('../chunk-HYPIHCDT.cjs');
|
|
9
9
|
require('../chunk-L47L3ZWJ.cjs');
|
|
10
10
|
require('../chunk-HDQ2JUQT.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
exports.ActorWorkflowContext =
|
|
15
|
+
exports.ActorWorkflowContext = _chunk7WF2QSICcjs.ActorWorkflowContext; exports.Loop = _chunk7WF2QSICcjs.Loop; exports.workflow = _chunk7WF2QSICcjs.workflow;
|
|
16
16
|
//# sourceMappingURL=mod.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as EventSchemaConfig, Q as QueueSchemaConfig, ad as RunContext } from '../config-
|
|
1
|
+
import { c as EventSchemaConfig, Q as QueueSchemaConfig, ad as RunContext } from '../config-iPj5l1bL.cjs';
|
|
2
2
|
import { A as AnyDatabaseProvider } from '../config-BiNoIHRs.cjs';
|
|
3
|
-
import { A as ActorWorkflowContext } from '../context-
|
|
4
|
-
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from '../context-
|
|
3
|
+
import { A as ActorWorkflowContext } from '../context-DzvH1PBK.cjs';
|
|
4
|
+
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from '../context-DzvH1PBK.cjs';
|
|
5
5
|
export { Loop } from '@rivetkit/workflow-engine';
|
|
6
6
|
import 'zod/v4';
|
|
7
7
|
import '@rivetkit/virtual-websocket';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as EventSchemaConfig, Q as QueueSchemaConfig, ad as RunContext } from '../config-
|
|
1
|
+
import { c as EventSchemaConfig, Q as QueueSchemaConfig, ad as RunContext } from '../config-Qj-zLJPc.js';
|
|
2
2
|
import { A as AnyDatabaseProvider } from '../config-BiNoIHRs.js';
|
|
3
|
-
import { A as ActorWorkflowContext } from '../context-
|
|
4
|
-
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from '../context-
|
|
3
|
+
import { A as ActorWorkflowContext } from '../context-CQCMuHND.js';
|
|
4
|
+
export { W as WorkflowBranchContextOf, a as WorkflowContextOf, b as WorkflowLoopContextOf, c as WorkflowStepContextOf } from '../context-CQCMuHND.js';
|
|
5
5
|
export { Loop } from '@rivetkit/workflow-engine';
|
|
6
6
|
import 'zod/v4';
|
|
7
7
|
import '@rivetkit/virtual-websocket';
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
ActorWorkflowContext,
|
|
3
3
|
Loop,
|
|
4
4
|
workflow
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-WY2SHWXQ.js";
|
|
6
|
+
import "../chunk-S662Y6ZU.js";
|
|
7
|
+
import "../chunk-TADUYCHF.js";
|
|
8
|
+
import "../chunk-EIATSBYZ.js";
|
|
9
9
|
import "../chunk-7HTNH26M.js";
|
|
10
10
|
import "../chunk-424PT5DM.js";
|
|
11
11
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivetkit",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Lightweight libraries for building stateful actors on edge platforms",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -219,11 +219,11 @@
|
|
|
219
219
|
"vbare": "^0.0.4",
|
|
220
220
|
"@rivetkit/sqlite": "^0.1.1",
|
|
221
221
|
"zod": "^4.1.0",
|
|
222
|
-
"@rivetkit/engine-runner": "2.1.
|
|
223
|
-
"@rivetkit/traces": "2.1.
|
|
224
|
-
"@rivetkit/
|
|
225
|
-
"@rivetkit/
|
|
226
|
-
"@rivetkit/
|
|
222
|
+
"@rivetkit/engine-runner": "2.1.5",
|
|
223
|
+
"@rivetkit/traces": "2.1.5",
|
|
224
|
+
"@rivetkit/workflow-engine": "2.1.5",
|
|
225
|
+
"@rivetkit/sqlite-vfs": "2.1.5",
|
|
226
|
+
"@rivetkit/virtual-websocket": "2.0.33"
|
|
227
227
|
},
|
|
228
228
|
"devDependencies": {
|
|
229
229
|
"@bare-ts/tools": "^0.13.0",
|
package/src/actor/config.ts
CHANGED
|
@@ -208,9 +208,7 @@ export const ActorConfigSchema = z
|
|
|
208
208
|
createVarsTimeout: z.number().positive().default(5000),
|
|
209
209
|
createConnStateTimeout: z.number().positive().default(5000),
|
|
210
210
|
onConnectTimeout: z.number().positive().default(5000),
|
|
211
|
-
// This must be less than engine config > pegboard.actor_stop_threshold
|
|
212
211
|
onSleepTimeout: z.number().positive().default(5000),
|
|
213
|
-
// This must be less than engine config > pegboard.actor_stop_threshold
|
|
214
212
|
onDestroyTimeout: z.number().positive().default(5000),
|
|
215
213
|
stateSaveInterval: z.number().positive().default(10_000),
|
|
216
214
|
actionTimeout: z.number().positive().default(60_000),
|
|
@@ -195,6 +195,19 @@ export class ActorInstance<
|
|
|
195
195
|
// MARK: - Tracing
|
|
196
196
|
#traces!: Traces<OtlpExportTraceServiceRequestJson>;
|
|
197
197
|
|
|
198
|
+
// MARK: - Driver Overrides
|
|
199
|
+
/**
|
|
200
|
+
* Per-instance config option overrides applied by the driver after creation.
|
|
201
|
+
* When set, the effective option value is the minimum of the base config
|
|
202
|
+
* value and the override value.
|
|
203
|
+
*/
|
|
204
|
+
overrides: {
|
|
205
|
+
onSleepTimeout?: number;
|
|
206
|
+
onDestroyTimeout?: number;
|
|
207
|
+
runStopTimeout?: number;
|
|
208
|
+
waitUntilTimeout?: number;
|
|
209
|
+
} = {};
|
|
210
|
+
|
|
198
211
|
// MARK: - Constructor
|
|
199
212
|
constructor(config: ActorConfig<S, CP, CS, V, I, DB, E, Q>) {
|
|
200
213
|
this.#config = config;
|
|
@@ -495,7 +508,7 @@ export class ActorInstance<
|
|
|
495
508
|
} catch { }
|
|
496
509
|
|
|
497
510
|
// Wait for run handler to complete
|
|
498
|
-
await this.#waitForRunHandler(this.#config.options.runStopTimeout);
|
|
511
|
+
await this.#waitForRunHandler(this.overrides.runStopTimeout !== undefined ? Math.min(this.#config.options.runStopTimeout, this.overrides.runStopTimeout) : this.#config.options.runStopTimeout);
|
|
499
512
|
|
|
500
513
|
// Call onStop lifecycle
|
|
501
514
|
if (mode === "sleep") {
|
|
@@ -511,7 +524,7 @@ export class ActorInstance<
|
|
|
511
524
|
|
|
512
525
|
// Wait for background tasks
|
|
513
526
|
await this.#waitBackgroundPromises(
|
|
514
|
-
this.#config.options.waitUntilTimeout,
|
|
527
|
+
this.overrides.waitUntilTimeout !== undefined ? Math.min(this.#config.options.waitUntilTimeout, this.overrides.waitUntilTimeout) : this.#config.options.waitUntilTimeout,
|
|
515
528
|
);
|
|
516
529
|
|
|
517
530
|
// Clear timeouts and save state
|
|
@@ -1265,7 +1278,7 @@ export class ActorInstance<
|
|
|
1265
1278
|
if (result instanceof Promise) {
|
|
1266
1279
|
await deadline(
|
|
1267
1280
|
result,
|
|
1268
|
-
this.#config.options.onSleepTimeout,
|
|
1281
|
+
this.overrides.onSleepTimeout !== undefined ? Math.min(this.#config.options.onSleepTimeout, this.overrides.onSleepTimeout) : this.#config.options.onSleepTimeout,
|
|
1269
1282
|
);
|
|
1270
1283
|
}
|
|
1271
1284
|
},
|
|
@@ -1297,7 +1310,7 @@ export class ActorInstance<
|
|
|
1297
1310
|
if (result instanceof Promise) {
|
|
1298
1311
|
await deadline(
|
|
1299
1312
|
result,
|
|
1300
|
-
this.#config.options.onDestroyTimeout,
|
|
1313
|
+
this.overrides.onDestroyTimeout !== undefined ? Math.min(this.#config.options.onDestroyTimeout, this.overrides.onDestroyTimeout) : this.#config.options.onDestroyTimeout,
|
|
1301
1314
|
);
|
|
1302
1315
|
}
|
|
1303
1316
|
},
|
package/src/actor/router.ts
CHANGED
|
@@ -20,11 +20,10 @@ import {
|
|
|
20
20
|
} from "@/common/router";
|
|
21
21
|
import { noopNext } from "@/common/utils";
|
|
22
22
|
import { inspectorLogger } from "@/inspector/log";
|
|
23
|
-
import { timingSafeEqual } from "@/utils/crypto";
|
|
24
|
-
import { getNodeEnv } from "@/utils/env-vars";
|
|
25
|
-
|
|
26
23
|
import type { RegistryConfig } from "@/registry/config";
|
|
27
24
|
import { type GetUpgradeWebSocket, VERSION } from "@/utils";
|
|
25
|
+
import { timingSafeEqual } from "@/utils/crypto";
|
|
26
|
+
import { isDev } from "@/utils/env-vars";
|
|
28
27
|
import { CONN_DRIVER_SYMBOL } from "./conn/mod";
|
|
29
28
|
import type { ActorDriver } from "./driver";
|
|
30
29
|
import { loggerWithoutContext } from "./log";
|
|
@@ -167,14 +166,16 @@ export function createActorRouter(
|
|
|
167
166
|
if (config.inspector.enabled) {
|
|
168
167
|
// Auth middleware for inspector routes
|
|
169
168
|
const inspectorAuth = async (c: any): Promise<Response | undefined> => {
|
|
170
|
-
if (
|
|
169
|
+
if (isDev() && !config.inspector.token()) {
|
|
171
170
|
inspectorLogger().warn({
|
|
172
171
|
msg: "RIVET_INSPECTOR_TOKEN is not set, skipping inspector auth in development mode",
|
|
173
172
|
});
|
|
174
173
|
return undefined;
|
|
175
174
|
}
|
|
176
175
|
|
|
177
|
-
const userToken = c.req
|
|
176
|
+
const userToken = c.req
|
|
177
|
+
.header("Authorization")
|
|
178
|
+
?.replace("Bearer ", "");
|
|
178
179
|
if (!userToken) {
|
|
179
180
|
return c.text("Unauthorized", 401);
|
|
180
181
|
}
|
|
@@ -197,7 +198,9 @@ export function createActorRouter(
|
|
|
197
198
|
|
|
198
199
|
const actor = await actorDriver.loadActor(c.env.actorId);
|
|
199
200
|
const isStateEnabled = actor.inspector.isStateEnabled();
|
|
200
|
-
const state = isStateEnabled
|
|
201
|
+
const state = isStateEnabled
|
|
202
|
+
? actor.inspector.getStateJson()
|
|
203
|
+
: undefined;
|
|
201
204
|
return c.json({ state, isStateEnabled });
|
|
202
205
|
});
|
|
203
206
|
|
|
@@ -17,6 +17,7 @@ import { runActorConnTests } from "./tests/actor-conn";
|
|
|
17
17
|
import { runActorConnHibernationTests } from "./tests/actor-conn-hibernation";
|
|
18
18
|
import { runActorConnStateTests } from "./tests/actor-conn-state";
|
|
19
19
|
import { runActorDbTests } from "./tests/actor-db";
|
|
20
|
+
import { runConnErrorSerializationTests } from "./tests/conn-error-serialization";
|
|
20
21
|
import { runActorDestroyTests } from "./tests/actor-destroy";
|
|
21
22
|
import { runActorDriverTests } from "./tests/actor-driver";
|
|
22
23
|
import { runActorErrorHandlingTests } from "./tests/actor-error-handling";
|
|
@@ -111,6 +112,8 @@ export function runDriverTests(
|
|
|
111
112
|
|
|
112
113
|
runActorConnHibernationTests(driverTestConfig);
|
|
113
114
|
|
|
115
|
+
runConnErrorSerializationTests(driverTestConfig);
|
|
116
|
+
|
|
114
117
|
runActorDbTests(driverTestConfig);
|
|
115
118
|
|
|
116
119
|
runActorDestroyTests(driverTestConfig);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe } from "vitest";
|
|
2
2
|
import type { DriverTestConfig } from "../mod";
|
|
3
|
+
import { runActorLifecycleTests } from "./actor-lifecycle";
|
|
3
4
|
import { runActorScheduleTests } from "./actor-schedule";
|
|
4
5
|
import { runActorSleepTests } from "./actor-sleep";
|
|
5
6
|
import { runActorStateTests } from "./actor-state";
|
|
@@ -14,5 +15,8 @@ export function runActorDriverTests(driverTestConfig: DriverTestConfig) {
|
|
|
14
15
|
|
|
15
16
|
// Run actor sleep tests
|
|
16
17
|
runActorSleepTests(driverTestConfig);
|
|
18
|
+
|
|
19
|
+
// Run actor lifecycle tests
|
|
20
|
+
runActorLifecycleTests(driverTestConfig);
|
|
17
21
|
});
|
|
18
22
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import type { DriverTestConfig } from "../mod";
|
|
3
|
+
import { setupDriverTest } from "../utils";
|
|
4
|
+
|
|
5
|
+
export function runActorLifecycleTests(driverTestConfig: DriverTestConfig) {
|
|
6
|
+
describe("Actor Lifecycle Tests", () => {
|
|
7
|
+
test("actor stop during start waits for start to complete", async (c) => {
|
|
8
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
9
|
+
|
|
10
|
+
const actorKey = `test-stop-during-start-${Date.now()}`;
|
|
11
|
+
|
|
12
|
+
// Create actor - this starts the actor
|
|
13
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
14
|
+
|
|
15
|
+
// Immediately try to call an action and then destroy
|
|
16
|
+
// This creates a race where the actor might not be fully started yet
|
|
17
|
+
const pingPromise = actor.ping();
|
|
18
|
+
|
|
19
|
+
// Get actor ID
|
|
20
|
+
const actorId = await actor.resolve();
|
|
21
|
+
|
|
22
|
+
// Destroy immediately while start might still be in progress
|
|
23
|
+
await actor.destroy();
|
|
24
|
+
|
|
25
|
+
// The ping should still complete successfully because destroy waits for start
|
|
26
|
+
const result = await pingPromise;
|
|
27
|
+
expect(result).toBe("pong");
|
|
28
|
+
|
|
29
|
+
// Verify actor was actually destroyed
|
|
30
|
+
let destroyed = false;
|
|
31
|
+
try {
|
|
32
|
+
await client.startStopRaceActor.getForId(actorId).ping();
|
|
33
|
+
} catch (err: any) {
|
|
34
|
+
destroyed = true;
|
|
35
|
+
expect(err.group).toBe("actor");
|
|
36
|
+
expect(err.code).toBe("not_found");
|
|
37
|
+
}
|
|
38
|
+
expect(destroyed).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("actor stop before actor instantiation completes cleans up handler", async (c) => {
|
|
42
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
43
|
+
|
|
44
|
+
const actorKey = `test-stop-before-instantiation-${Date.now()}`;
|
|
45
|
+
|
|
46
|
+
// Create multiple actors rapidly to increase chance of race
|
|
47
|
+
const actors = Array.from({ length: 5 }, (_, i) =>
|
|
48
|
+
client.startStopRaceActor.getOrCreate([
|
|
49
|
+
`${actorKey}-${i}`,
|
|
50
|
+
]),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// Resolve all actor IDs (this triggers start)
|
|
54
|
+
const ids = await Promise.all(actors.map((a) => a.resolve()));
|
|
55
|
+
|
|
56
|
+
// Immediately destroy all actors
|
|
57
|
+
await Promise.all(actors.map((a) => a.destroy()));
|
|
58
|
+
|
|
59
|
+
// Verify all actors were cleaned up
|
|
60
|
+
for (const id of ids) {
|
|
61
|
+
let destroyed = false;
|
|
62
|
+
try {
|
|
63
|
+
await client.startStopRaceActor.getForId(id).ping();
|
|
64
|
+
} catch (err: any) {
|
|
65
|
+
destroyed = true;
|
|
66
|
+
expect(err.group).toBe("actor");
|
|
67
|
+
expect(err.code).toBe("not_found");
|
|
68
|
+
}
|
|
69
|
+
expect(destroyed, `actor ${id} should be destroyed`).toBe(
|
|
70
|
+
true,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("onBeforeActorStart completes before stop proceeds", async (c) => {
|
|
76
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
77
|
+
|
|
78
|
+
const actorKey = `test-before-actor-start-${Date.now()}`;
|
|
79
|
+
|
|
80
|
+
// Create actor
|
|
81
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
82
|
+
|
|
83
|
+
// Call action to ensure actor is starting
|
|
84
|
+
const statePromise = actor.getState();
|
|
85
|
+
|
|
86
|
+
// Destroy immediately
|
|
87
|
+
await actor.destroy();
|
|
88
|
+
|
|
89
|
+
// State should be initialized because onBeforeActorStart must complete
|
|
90
|
+
const state = await statePromise;
|
|
91
|
+
expect(state.initialized).toBe(true);
|
|
92
|
+
expect(state.startCompleted).toBe(true);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("multiple rapid create/destroy cycles handle race correctly", async (c) => {
|
|
96
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
97
|
+
|
|
98
|
+
// Perform multiple rapid create/destroy cycles
|
|
99
|
+
for (let i = 0; i < 10; i++) {
|
|
100
|
+
const actorKey = `test-rapid-cycle-${Date.now()}-${i}`;
|
|
101
|
+
const actor = client.startStopRaceActor.getOrCreate([
|
|
102
|
+
actorKey,
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
// Trigger start
|
|
106
|
+
const resolvePromise = actor.resolve();
|
|
107
|
+
|
|
108
|
+
// Immediately destroy
|
|
109
|
+
const destroyPromise = actor.destroy();
|
|
110
|
+
|
|
111
|
+
// Both should complete without errors
|
|
112
|
+
await Promise.all([resolvePromise, destroyPromise]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// If we get here without errors, the race condition is handled correctly
|
|
116
|
+
expect(true).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("actor stop called with no actor instance cleans up handler", async (c) => {
|
|
120
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
121
|
+
|
|
122
|
+
const actorKey = `test-cleanup-no-instance-${Date.now()}`;
|
|
123
|
+
|
|
124
|
+
// Create and immediately destroy
|
|
125
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
126
|
+
const id = await actor.resolve();
|
|
127
|
+
await actor.destroy();
|
|
128
|
+
|
|
129
|
+
// Try to recreate with same key - should work without issues
|
|
130
|
+
const newActor = client.startStopRaceActor.getOrCreate([
|
|
131
|
+
actorKey,
|
|
132
|
+
]);
|
|
133
|
+
const result = await newActor.ping();
|
|
134
|
+
expect(result).toBe("pong");
|
|
135
|
+
|
|
136
|
+
// Clean up
|
|
137
|
+
await newActor.destroy();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test("onDestroy is called even when actor is destroyed during start", async (c) => {
|
|
141
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
142
|
+
|
|
143
|
+
const actorKey = `test-ondestroy-during-start-${Date.now()}`;
|
|
144
|
+
|
|
145
|
+
// Create actor
|
|
146
|
+
const actor = client.startStopRaceActor.getOrCreate([actorKey]);
|
|
147
|
+
|
|
148
|
+
// Start and immediately destroy
|
|
149
|
+
const statePromise = actor.getState();
|
|
150
|
+
await actor.destroy();
|
|
151
|
+
|
|
152
|
+
// Verify onDestroy was called (requires actor to be started)
|
|
153
|
+
const state = await statePromise;
|
|
154
|
+
expect(state.destroyCalled).toBe(true);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import type { DriverTestConfig } from "../mod";
|
|
3
|
+
import { setupDriverTest } from "../utils";
|
|
4
|
+
|
|
5
|
+
export function runConnErrorSerializationTests(driverTestConfig: DriverTestConfig) {
|
|
6
|
+
describe("Connection Error Serialization Tests", () => {
|
|
7
|
+
test("error thrown in createConnState preserves group and code through WebSocket serialization", async (c) => {
|
|
8
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
9
|
+
|
|
10
|
+
const actorKey = `test-error-serialization-${Date.now()}`;
|
|
11
|
+
|
|
12
|
+
// Create actor handle with params that will trigger error in createConnState
|
|
13
|
+
const actor = client.connErrorSerializationActor.getOrCreate(
|
|
14
|
+
[actorKey],
|
|
15
|
+
{ params: { shouldThrow: true } },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// Try to connect, which will trigger error in createConnState
|
|
19
|
+
const conn = actor.connect();
|
|
20
|
+
|
|
21
|
+
// Wait for connection to fail
|
|
22
|
+
let caughtError: any;
|
|
23
|
+
try {
|
|
24
|
+
// Try to call an action, which should fail because connection couldn't be established
|
|
25
|
+
await conn.getValue();
|
|
26
|
+
} catch (err) {
|
|
27
|
+
caughtError = err;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Verify the error was caught
|
|
31
|
+
expect(caughtError).toBeDefined();
|
|
32
|
+
|
|
33
|
+
// Verify the error has the correct group and code from the original error
|
|
34
|
+
// Original error: new CustomConnectionError("...") with group="connection", code="custom_error"
|
|
35
|
+
expect(caughtError.group).toBe("connection");
|
|
36
|
+
expect(caughtError.code).toBe("custom_error");
|
|
37
|
+
|
|
38
|
+
// Clean up
|
|
39
|
+
await conn.dispose();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("successful createConnState does not throw error", async (c) => {
|
|
43
|
+
const { client } = await setupDriverTest(c, driverTestConfig);
|
|
44
|
+
|
|
45
|
+
const actorKey = `test-no-error-${Date.now()}`;
|
|
46
|
+
|
|
47
|
+
// Create actor handle with params that will NOT trigger error
|
|
48
|
+
const actor = client.connErrorSerializationActor.getOrCreate(
|
|
49
|
+
[actorKey],
|
|
50
|
+
{ params: { shouldThrow: false } },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// Connect without triggering error
|
|
54
|
+
const conn = actor.connect();
|
|
55
|
+
|
|
56
|
+
// This should succeed
|
|
57
|
+
const value = await conn.getValue();
|
|
58
|
+
expect(value).toBe(0);
|
|
59
|
+
|
|
60
|
+
// Clean up
|
|
61
|
+
await conn.dispose();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|