rivetkit 2.3.0-rc.9 → 2.3.0
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 +498 -62
- package/dist/browser/client.js +227 -171
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +50 -20
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/actor/errors.cjs +2 -2
- package/dist/tsup/actor/errors.d.cts +1 -1
- package/dist/tsup/actor/errors.d.ts +1 -1
- package/dist/tsup/actor/errors.js +1 -1
- package/dist/tsup/agent-os/index.cjs +2163 -2087
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +496 -69
- package/dist/tsup/agent-os/index.d.ts +496 -69
- package/dist/tsup/agent-os/index.js +2163 -2087
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-W7EYSYVI.js → chunk-2OTRTA3J.js} +134 -20
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-VJFRBJVQ.cjs → chunk-3677IIOV.cjs} +138 -24
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-4CGA6QJO.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-F3Q5BFQ6.js → chunk-4JDSFJS5.js} +66 -79
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-GVTOE34S.cjs → chunk-7QKCIVAY.cjs} +222 -235
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-CPA4Y3RG.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/chunk-B6VUNZUD.cjs.map +1 -0
- package/dist/tsup/{chunk-H37XQU3I.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-KIWH5H3K.js → chunk-BRP62GZC.js} +3 -3
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-T6YVRM4K.js → chunk-DPIMKYNB.js} +63 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-Y5NSCZA2.cjs → chunk-DXXJPH55.cjs} +44 -15
- package/dist/tsup/chunk-DXXJPH55.cjs.map +1 -0
- package/dist/tsup/{chunk-3YY5S6TV.js → chunk-HXUEHHJF.js} +2 -2
- package/dist/tsup/chunk-HXUEHHJF.js.map +1 -0
- package/dist/tsup/{chunk-4WPEZBK4.cjs → chunk-I4LN3FNT.cjs} +10 -10
- package/dist/tsup/chunk-I4LN3FNT.cjs.map +1 -0
- package/dist/tsup/{chunk-PCBNKI2J.js → chunk-JZ7TWV65.js} +1 -1
- package/dist/tsup/chunk-JZ7TWV65.js.map +1 -0
- package/dist/tsup/{chunk-QAZLM4WT.cjs → chunk-KORQB2IR.cjs} +3 -3
- package/dist/tsup/{chunk-QAZLM4WT.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-MALSPBAF.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-MALSPBAF.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-H7P7WR2Y.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-WQ4HNA4W.cjs → chunk-NIY3RSPX.cjs} +64 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-MMMEZM5J.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/chunk-P2GNQ4RN.js.map +1 -0
- package/dist/tsup/{chunk-KJTA3ATT.js → chunk-UMZVD6DQ.js} +22 -7
- package/dist/tsup/chunk-UMZVD6DQ.js.map +1 -0
- package/dist/tsup/{chunk-LD5YASJU.cjs → chunk-VE2X4KMG.cjs} +2 -2
- package/dist/tsup/{chunk-LD5YASJU.cjs.map → chunk-VE2X4KMG.cjs.map} +1 -1
- package/dist/tsup/{chunk-VRCIXJRN.js → chunk-VTTFNQQI.js} +36 -7
- package/dist/tsup/chunk-VTTFNQQI.js.map +1 -0
- package/dist/tsup/{chunk-2NDZ7JCR.cjs → chunk-ZA7FLHKH.cjs} +1 -1
- package/dist/tsup/chunk-ZA7FLHKH.cjs.map +1 -0
- package/dist/tsup/client/mod.cjs +9 -9
- package/dist/tsup/client/mod.d.cts +5 -5
- package/dist/tsup/client/mod.d.ts +5 -5
- 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/{config-0Ta55UV0.d.ts → config-BxWAw3iH.d.ts} +529 -23
- package/dist/tsup/{config-Ca8dN4cS.d.cts → config-CZQQ-mso.d.cts} +529 -23
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-B_IWbWne.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-CUrQ9MHc.d.cts → context-D8QA76sV.d.ts} +8 -8
- package/dist/tsup/db/drizzle.cjs +3 -3
- package/dist/tsup/db/drizzle.d.cts +1 -1
- package/dist/tsup/db/drizzle.d.ts +1 -1
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +2 -2
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.cjs +24 -0
- package/dist/tsup/dynamic/mod.cjs.map +1 -0
- package/dist/tsup/dynamic/mod.d.cts +37 -0
- package/dist/tsup/dynamic/mod.d.ts +37 -0
- package/dist/tsup/dynamic/mod.js +24 -0
- package/dist/tsup/dynamic/mod.js.map +1 -0
- package/dist/tsup/inspector/mod.cjs +6 -6
- package/dist/tsup/inspector/mod.js +5 -5
- package/dist/tsup/inspector-tab/mod.cjs +173 -0
- package/dist/tsup/inspector-tab/mod.cjs.map +1 -0
- package/dist/tsup/inspector-tab/mod.d.cts +250 -0
- package/dist/tsup/inspector-tab/mod.d.ts +250 -0
- package/dist/tsup/inspector-tab/mod.js +173 -0
- package/dist/tsup/inspector-tab/mod.js.map +1 -0
- package/dist/tsup/mod.cjs +730 -336
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +5 -5
- package/dist/tsup/mod.d.ts +5 -5
- package/dist/tsup/mod.js +633 -239
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +21 -18
- package/dist/tsup/test/mod.cjs.map +1 -1
- package/dist/tsup/test/mod.d.cts +4 -4
- package/dist/tsup/test/mod.d.ts +4 -4
- package/dist/tsup/test/mod.js +18 -15
- package/dist/tsup/test/mod.js.map +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.cts → utils-DQosb24I.d.cts} +1 -1
- package/dist/tsup/{utils-DVekpm4I.d.ts → utils-DQosb24I.d.ts} +1 -1
- package/dist/tsup/utils.cjs +3 -3
- package/dist/tsup/utils.d.cts +1 -1
- package/dist/tsup/utils.d.ts +1 -1
- package/dist/tsup/utils.js +2 -2
- package/dist/tsup/workflow/mod.cjs +307 -282
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +6 -6
- package/dist/tsup/workflow/mod.d.ts +6 -6
- package/dist/tsup/workflow/mod.js +501 -476
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +32 -11
- package/src/actor/config.ts +159 -51
- package/src/actor/contexts/index.ts +7 -2
- package/src/actor/definition.ts +17 -19
- package/src/actor/driver.ts +3 -3
- package/src/actor/errors.ts +9 -3
- package/src/actor/instance/mod.ts +26 -34
- package/src/actor/keys.ts +1 -1
- package/src/actor/mod.ts +22 -20
- package/src/actor/schema.ts +2 -2
- package/src/agent-os/actor/index.ts +38 -18
- package/src/agent-os/actor/preview.ts +1 -2
- package/src/agent-os/actor/session.ts +2 -2
- package/src/agent-os/config.ts +1 -1
- package/src/agent-os/fs/database-vfs.ts +1 -1
- package/src/agent-os/index.ts +16 -15
- package/src/client/actor-common.ts +87 -54
- package/src/client/actor-conn.ts +8 -36
- package/src/client/actor-handle.ts +69 -51
- package/src/client/actor-query.ts +5 -5
- package/src/client/errors.ts +1 -1
- package/src/client/lifecycle-errors.ts +2 -4
- package/src/client/query.ts +1 -1
- package/src/client/queue.ts +8 -3
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -7
- package/src/common/actor-websocket.ts +3 -1
- package/src/common/bare/actor-persist/v1.ts +205 -163
- package/src/common/bare/actor-persist/v2.ts +265 -213
- package/src/common/bare/actor-persist/v3.ts +176 -172
- package/src/common/bare/actor-persist/v4.ts +254 -253
- package/src/common/bare/transport/v1.ts +659 -543
- package/src/common/client-protocol-versioned.ts +66 -64
- package/src/common/database/config.ts +2 -8
- package/src/common/database/native-database.ts +1 -1
- package/src/common/database/shared.ts +1 -0
- package/src/common/encoding.ts +250 -16
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +14 -13
- package/src/common/log.ts +1 -0
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -150
- package/src/common/websocket-interface.ts +1 -1
- package/src/db/mod.ts +1 -1
- package/src/devtools-loader/index.ts +4 -7
- package/src/devtools-loader/serve-devtools.ts +26 -0
- package/src/drivers/engine/actor-driver.ts +58 -56
- package/src/dynamic/instance.ts +32 -0
- package/src/dynamic/internal.ts +50 -0
- package/src/dynamic/isolate-runtime.ts +66 -0
- package/src/dynamic/mod.ts +32 -0
- package/src/engine-client/actor-http-client.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +6 -5
- package/src/engine-client/api-endpoints.ts +51 -2
- package/src/engine-client/api-utils.ts +2 -2
- package/src/engine-client/driver.ts +1 -1
- package/src/engine-client/mod.ts +6 -3
- package/src/engine-client/ws-proxy.ts +9 -4
- package/src/inspector/client.browser.ts +5 -11
- package/src/inspector/mod.ts +1 -3
- package/src/inspector-tab/mod.ts +315 -0
- package/src/registry/config/envoy.ts +1 -2
- package/src/registry/config/index.ts +40 -16
- package/src/registry/index.ts +154 -74
- package/src/registry/napi-runtime.ts +13 -2
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +367 -181
- package/src/registry/process-metrics.ts +250 -0
- package/src/registry/runtime.ts +41 -1
- package/src/registry/wasm-runtime.ts +18 -2
- package/src/registry/write-through-proxy.ts +40 -0
- package/src/serde.ts +2 -2
- package/src/serverless/configure.ts +18 -7
- package/src/test/mod.ts +11 -8
- package/src/utils/endpoint-parser.ts +1 -1
- package/src/utils/env-vars.ts +6 -0
- package/src/utils/router.ts +1 -1
- package/src/utils/serve.ts +4 -5
- package/src/utils.ts +1 -2
- package/src/workflow/context.ts +61 -33
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +4 -3
- package/src/workflow/mod.ts +15 -17
- package/dist/tsup/chunk-2NDZ7JCR.cjs.map +0 -1
- package/dist/tsup/chunk-3YY5S6TV.js.map +0 -1
- package/dist/tsup/chunk-4CGA6QJO.cjs.map +0 -1
- package/dist/tsup/chunk-4WPEZBK4.cjs.map +0 -1
- package/dist/tsup/chunk-CPA4Y3RG.cjs.map +0 -1
- package/dist/tsup/chunk-F3Q5BFQ6.js.map +0 -1
- package/dist/tsup/chunk-GVTOE34S.cjs.map +0 -1
- package/dist/tsup/chunk-H7P7WR2Y.js.map +0 -1
- package/dist/tsup/chunk-KIWH5H3K.js.map +0 -1
- package/dist/tsup/chunk-KJTA3ATT.js.map +0 -1
- package/dist/tsup/chunk-MMMEZM5J.js.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-T6YVRM4K.js.map +0 -1
- package/dist/tsup/chunk-VJFRBJVQ.cjs.map +0 -1
- package/dist/tsup/chunk-VRCIXJRN.js.map +0 -1
- package/dist/tsup/chunk-W7EYSYVI.js.map +0 -1
- package/dist/tsup/chunk-WQ4HNA4W.cjs.map +0 -1
- package/dist/tsup/chunk-Y5NSCZA2.cjs.map +0 -1
- /package/dist/tsup/{chunk-H37XQU3I.js.map → chunk-BEI24WTI.js.map} +0 -0
package/src/common/router.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import type { Context as HonoContext, Next } from "hono";
|
|
2
1
|
import * as envoyProtocol from "@rivetkit/engine-envoy-protocol";
|
|
2
|
+
import type { Context as HonoContext, Next } from "hono";
|
|
3
3
|
import type { ActorSpecifier } from "@/actor/errors";
|
|
4
4
|
import {
|
|
5
5
|
HEADER_ACTOR_GENERATION,
|
|
6
6
|
HEADER_ACTOR_ID,
|
|
7
7
|
HEADER_ACTOR_KEY,
|
|
8
8
|
} from "@/common/actor-router-consts";
|
|
9
|
-
import type { Encoding } from "@/common/encoding";
|
|
10
|
-
import {
|
|
11
|
-
getRequestEncoding,
|
|
12
|
-
getRequestExposeInternalError,
|
|
13
|
-
} from "@/common/router-request";
|
|
14
|
-
import { buildActorNames, type RegistryConfig } from "@/registry/config";
|
|
15
9
|
import type * as protocol from "@/common/client-protocol";
|
|
16
10
|
import {
|
|
17
11
|
CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
@@ -21,15 +15,17 @@ import {
|
|
|
21
15
|
type HttpResponseError as HttpResponseErrorJson,
|
|
22
16
|
HttpResponseErrorSchema,
|
|
23
17
|
} from "@/common/client-protocol-zod";
|
|
18
|
+
import type { Encoding, JsonCompatValue } from "@/common/encoding";
|
|
24
19
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} from "@/
|
|
20
|
+
getRequestEncoding,
|
|
21
|
+
getRequestExposeInternalError,
|
|
22
|
+
} from "@/common/router-request";
|
|
23
|
+
import { buildActorNames, type RegistryConfig } from "@/registry/config";
|
|
24
|
+
import { encodeCborCompat, serializeWithEncoding } from "@/serde";
|
|
29
25
|
import { bufferToArrayBuffer, VERSION } from "@/utils";
|
|
30
26
|
import { getLogHeaders } from "@/utils/env-vars";
|
|
31
27
|
import { getLogger, type Logger } from "./log";
|
|
32
|
-
import { deconstructError
|
|
28
|
+
import { deconstructError } from "./utils";
|
|
33
29
|
|
|
34
30
|
export function logger() {
|
|
35
31
|
return getLogger("router");
|
|
@@ -67,10 +63,8 @@ export function handleRouteNotFound(c: HonoContext) {
|
|
|
67
63
|
export function handleRouteError(error: unknown, c: HonoContext) {
|
|
68
64
|
const exposeInternalError = getRequestExposeInternalError(c.req.raw);
|
|
69
65
|
|
|
70
|
-
const { statusCode, group, code, message, metadata, actor } =
|
|
71
|
-
error,
|
|
72
|
-
exposeInternalError,
|
|
73
|
-
);
|
|
66
|
+
const { statusCode, group, code, message, metadata, actor } =
|
|
67
|
+
deconstructError(error, exposeInternalError);
|
|
74
68
|
|
|
75
69
|
if (actor) {
|
|
76
70
|
logger().warn({
|
|
@@ -111,7 +105,9 @@ export function handleRouteError(error: unknown, c: HonoContext) {
|
|
|
111
105
|
code: value.code,
|
|
112
106
|
message: value.message,
|
|
113
107
|
metadata: value.metadata
|
|
114
|
-
? bufferToArrayBuffer(
|
|
108
|
+
? bufferToArrayBuffer(
|
|
109
|
+
encodeCborCompat(value.metadata as JsonCompatValue),
|
|
110
|
+
)
|
|
115
111
|
: null,
|
|
116
112
|
actor: value.actor
|
|
117
113
|
? {
|
package/src/common/utils.ts
CHANGED
|
@@ -36,155 +36,6 @@ export function safeStringify(obj: unknown, maxSize: number) {
|
|
|
36
36
|
return JSON.stringify(obj, replacer);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
// TODO: Instead of doing this, use a temp var for state and attempt to write
|
|
40
|
-
// it. Roll back state if fails to serialize.
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Check if a value is CBOR serializable.
|
|
44
|
-
* Optionally pass an onInvalid callback to receive the path to invalid values.
|
|
45
|
-
*
|
|
46
|
-
* For a complete list of supported CBOR tags, see:
|
|
47
|
-
* https://github.com/kriszyp/cbor-x/blob/cc1cf9df8ba72288c7842af1dd374d73e34cdbc1/README.md#list-of-supported-tags-for-decoding
|
|
48
|
-
*/
|
|
49
|
-
export function isCborSerializable(
|
|
50
|
-
value: unknown,
|
|
51
|
-
onInvalid?: (path: string) => void,
|
|
52
|
-
currentPath = "",
|
|
53
|
-
): boolean {
|
|
54
|
-
// Handle primitive types directly
|
|
55
|
-
if (value === null || value === undefined) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (typeof value === "number") {
|
|
60
|
-
if (!Number.isFinite(value)) {
|
|
61
|
-
onInvalid?.(currentPath);
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (typeof value === "boolean" || typeof value === "string") {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Handle BigInt (CBOR tags 2 and 3)
|
|
72
|
-
if (typeof value === "bigint") {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Handle Date objects (CBOR tags 0 and 1)
|
|
77
|
-
if (value instanceof Date) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Handle typed arrays (CBOR tags 64-82)
|
|
82
|
-
if (
|
|
83
|
-
value instanceof Uint8Array ||
|
|
84
|
-
value instanceof Uint8ClampedArray ||
|
|
85
|
-
value instanceof Uint16Array ||
|
|
86
|
-
value instanceof Uint32Array ||
|
|
87
|
-
value instanceof BigUint64Array ||
|
|
88
|
-
value instanceof Int8Array ||
|
|
89
|
-
value instanceof Int16Array ||
|
|
90
|
-
value instanceof Int32Array ||
|
|
91
|
-
value instanceof BigInt64Array ||
|
|
92
|
-
value instanceof Float32Array ||
|
|
93
|
-
value instanceof Float64Array
|
|
94
|
-
) {
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Handle Map (CBOR tag 259)
|
|
99
|
-
if (value instanceof Map) {
|
|
100
|
-
for (const [key, val] of value.entries()) {
|
|
101
|
-
const keyPath = currentPath
|
|
102
|
-
? `${currentPath}.key(${String(key)})`
|
|
103
|
-
: `key(${String(key)})`;
|
|
104
|
-
const valPath = currentPath
|
|
105
|
-
? `${currentPath}.value(${String(key)})`
|
|
106
|
-
: `value(${String(key)})`;
|
|
107
|
-
if (
|
|
108
|
-
!isCborSerializable(key, onInvalid, keyPath) ||
|
|
109
|
-
!isCborSerializable(val, onInvalid, valPath)
|
|
110
|
-
) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Handle Set (CBOR tag 258)
|
|
118
|
-
if (value instanceof Set) {
|
|
119
|
-
let index = 0;
|
|
120
|
-
for (const item of value.values()) {
|
|
121
|
-
const itemPath = currentPath
|
|
122
|
-
? `${currentPath}.set[${index}]`
|
|
123
|
-
: `set[${index}]`;
|
|
124
|
-
if (!isCborSerializable(item, onInvalid, itemPath)) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
index++;
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Handle RegExp (CBOR tag 27)
|
|
133
|
-
if (value instanceof RegExp) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Handle Error objects (CBOR tag 27)
|
|
138
|
-
if (value instanceof Error) {
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Handle arrays
|
|
143
|
-
if (Array.isArray(value)) {
|
|
144
|
-
for (let i = 0; i < value.length; i++) {
|
|
145
|
-
const itemPath = currentPath ? `${currentPath}[${i}]` : `[${i}]`;
|
|
146
|
-
if (!isCborSerializable(value[i], onInvalid, itemPath)) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Handle plain objects and records (CBOR tags 105, 51, 57344-57599)
|
|
154
|
-
if (typeof value === "object") {
|
|
155
|
-
// Allow plain objects and objects with prototypes (for records and named objects)
|
|
156
|
-
const proto = Object.getPrototypeOf(value);
|
|
157
|
-
if (proto !== null && proto !== Object.prototype) {
|
|
158
|
-
// Check if it's a known serializable object type
|
|
159
|
-
const protoConstructor = value.constructor;
|
|
160
|
-
if (protoConstructor && typeof protoConstructor.name === "string") {
|
|
161
|
-
// Allow objects with named constructors (records, named objects)
|
|
162
|
-
// This includes user-defined classes and built-in objects
|
|
163
|
-
// that CBOR can serialize with tag 27 or record tags
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Check all properties recursively
|
|
168
|
-
for (const key in value) {
|
|
169
|
-
const propPath = currentPath ? `${currentPath}.${key}` : key;
|
|
170
|
-
if (
|
|
171
|
-
!isCborSerializable(
|
|
172
|
-
value[key as keyof typeof value],
|
|
173
|
-
onInvalid,
|
|
174
|
-
propPath,
|
|
175
|
-
)
|
|
176
|
-
) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return true;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Not serializable
|
|
184
|
-
onInvalid?.(currentPath);
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
39
|
export interface DeconstructedError {
|
|
189
40
|
__type: "ActorError";
|
|
190
41
|
statusCode: ContentfulStatusCode;
|
|
@@ -283,7 +134,7 @@ export function deconstructError(
|
|
|
283
134
|
actor = error.actor;
|
|
284
135
|
}
|
|
285
136
|
metadata = {
|
|
286
|
-
//url: `https://
|
|
137
|
+
//url: `https://dashboard.rivet.dev/projects/${actorMetadata.project.slug}/environments/${actorMetadata.environment.slug}/actors?actorId=${actorMetadata.actor.id}`,
|
|
287
138
|
} satisfies errors.InternalErrorMetadata;
|
|
288
139
|
}
|
|
289
140
|
|
package/src/db/mod.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { db } from "@/common/database/mod";
|
|
2
1
|
export type {
|
|
3
2
|
AnyDatabaseProvider,
|
|
4
3
|
DatabaseProvider,
|
|
@@ -11,3 +10,4 @@ export type {
|
|
|
11
10
|
SqliteNativeMetrics,
|
|
12
11
|
SqliteQueryResult,
|
|
13
12
|
} from "@/common/database/config";
|
|
13
|
+
export { db } from "@/common/database/mod";
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { ClientConfigInput } from "@/client/client";
|
|
2
|
-
import { VERSION } from "@/utils";
|
|
3
2
|
import { logger } from "./log";
|
|
4
3
|
|
|
5
4
|
declare global {
|
|
6
5
|
// Injected via tsup config
|
|
7
|
-
// biome-ignore lint/style/noVar: required for global declaration
|
|
8
6
|
var CUSTOM_RIVETKIT_DEVTOOLS_URL: string | undefined;
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
const DEFAULT_DEVTOOLS_URL = (version = VERSION) =>
|
|
12
|
-
`https://releases.rivet.dev/rivet/latest/devtools/mod.js?v=${version}`;
|
|
13
|
-
|
|
14
9
|
const scriptId = "rivetkit-devtools-script";
|
|
15
10
|
|
|
16
11
|
export function injectDevtools(config: ClientConfigInput) {
|
|
@@ -20,10 +15,12 @@ export function injectDevtools(config: ClientConfigInput) {
|
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
if (!document.getElementById(scriptId)) {
|
|
18
|
+
const src =
|
|
19
|
+
globalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL ||
|
|
20
|
+
`${config.endpoint?.replace(/\/$/, "")}/devtools/mod.js`;
|
|
23
21
|
const script = document.createElement("script");
|
|
24
22
|
script.id = scriptId;
|
|
25
|
-
script.src =
|
|
26
|
-
globalThis.CUSTOM_RIVETKIT_DEVTOOLS_URL || DEFAULT_DEVTOOLS_URL();
|
|
23
|
+
script.src = src;
|
|
27
24
|
script.async = true;
|
|
28
25
|
document.head.appendChild(script);
|
|
29
26
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getNodeFs, getNodePath, getNodeUrl } from "@/utils/node";
|
|
2
|
+
|
|
3
|
+
export async function getDevtoolsPath(): Promise<string> {
|
|
4
|
+
const url = getNodeUrl();
|
|
5
|
+
const path = getNodePath();
|
|
6
|
+
|
|
7
|
+
const devtoolsPath = path.join(
|
|
8
|
+
path.dirname(url.fileURLToPath(import.meta.url)),
|
|
9
|
+
"../../dist/devtools/mod.js",
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await getNodeFs().access(devtoolsPath);
|
|
14
|
+
} catch {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Devtools bundle not found at ${devtoolsPath}. Run 'pnpm build:pack-devtools' first.`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return devtoolsPath;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function readDevtoolsBundle(): Promise<Buffer> {
|
|
24
|
+
const devtoolsPath = await getDevtoolsPath();
|
|
25
|
+
return getNodeFs().readFile(devtoolsPath);
|
|
26
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EnvoyConfig } from "@rivetkit/rivetkit-native/wrapper";
|
|
2
2
|
import {
|
|
3
|
-
type HibernatingWebSocketMetadata,
|
|
4
3
|
type EnvoyHandle,
|
|
4
|
+
type HibernatingWebSocketMetadata,
|
|
5
5
|
openDatabaseFromEnvoy,
|
|
6
|
-
protocol,
|
|
6
|
+
type protocol,
|
|
7
7
|
startEnvoySync,
|
|
8
8
|
} from "@rivetkit/rivetkit-native/wrapper";
|
|
9
9
|
import * as cbor from "cbor-x";
|
|
@@ -11,17 +11,19 @@ import type { Context as HonoContext } from "hono";
|
|
|
11
11
|
import { streamSSE } from "hono/streaming";
|
|
12
12
|
import { WSContext, type WSContextInit } from "hono/ws";
|
|
13
13
|
import invariant from "invariant";
|
|
14
|
-
import {
|
|
14
|
+
import { CONN_STATE_MANAGER_SYMBOL } from "@/actor/conn/mod";
|
|
15
15
|
import { isStaticActorDefinition, lookupInRegistry } from "@/actor/definition";
|
|
16
|
+
import type { ActorDriver } from "@/actor/driver";
|
|
17
|
+
import { KEYS } from "@/actor/instance/keys";
|
|
18
|
+
import type { AnyActorInstance } from "@/actor/instance/mod";
|
|
16
19
|
import {
|
|
17
|
-
isStaticActorInstance,
|
|
18
20
|
type AnyStaticActorInstance,
|
|
21
|
+
isStaticActorInstance,
|
|
19
22
|
} from "@/actor/instance/mod";
|
|
20
|
-
import { KEYS } from "@/actor/instance/keys";
|
|
21
23
|
import {
|
|
22
|
-
type PreloadMap,
|
|
23
24
|
compareBytes,
|
|
24
25
|
createPreloadMap,
|
|
26
|
+
type PreloadMap,
|
|
25
27
|
} from "@/actor/instance/preload-map";
|
|
26
28
|
import { deserializeActorKey } from "@/actor/keys";
|
|
27
29
|
import type { Encoding } from "@/actor/protocol/serde";
|
|
@@ -41,6 +43,10 @@ import {
|
|
|
41
43
|
} from "@/common/actor-router-consts";
|
|
42
44
|
import { getLogger } from "@/common/log";
|
|
43
45
|
import { deconstructError } from "@/common/utils";
|
|
46
|
+
import type {
|
|
47
|
+
RivetMessageEvent,
|
|
48
|
+
UniversalWebSocket,
|
|
49
|
+
} from "@/common/websocket-interface";
|
|
44
50
|
import {
|
|
45
51
|
buildHibernatableWebSocketAckStateTestResponse,
|
|
46
52
|
type IndexedWebSocketPayload,
|
|
@@ -49,21 +55,19 @@ import {
|
|
|
49
55
|
setHibernatableWebSocketAckTestHooks,
|
|
50
56
|
unregisterRemoteHibernatableWebSocketAckHooks,
|
|
51
57
|
} from "@/common/websocket-test-hooks";
|
|
52
|
-
import type {
|
|
53
|
-
RivetMessageEvent,
|
|
54
|
-
UniversalWebSocket,
|
|
55
|
-
} from "@/common/websocket-interface";
|
|
56
|
-
import type { ActorDriver } from "@/actor/driver";
|
|
57
|
-
import type { AnyActorInstance } from "@/actor/instance/mod";
|
|
58
58
|
import {
|
|
59
|
-
|
|
59
|
+
type JsNativeDatabaseLike,
|
|
60
|
+
wrapJsNativeDatabase,
|
|
61
|
+
} from "@/db/native-database";
|
|
62
|
+
import {
|
|
60
63
|
type EngineControlClient,
|
|
64
|
+
getInitialActorKvState,
|
|
61
65
|
} from "@/driver-helpers/mod";
|
|
62
66
|
import { DynamicActorInstance } from "@/dynamic/instance";
|
|
63
|
-
import { DynamicActorIsolateRuntime } from "@/dynamic/isolate-runtime";
|
|
64
67
|
import { isDynamicActorDefinition } from "@/dynamic/internal";
|
|
65
|
-
import {
|
|
68
|
+
import { DynamicActorIsolateRuntime } from "@/dynamic/isolate-runtime";
|
|
66
69
|
import { getEndpoint } from "@/engine-client/api-utils";
|
|
70
|
+
import { buildActorNames, type RegistryConfig } from "@/registry/config";
|
|
67
71
|
import {
|
|
68
72
|
type LongTimeoutHandle,
|
|
69
73
|
promiseWithResolvers,
|
|
@@ -71,10 +75,6 @@ import {
|
|
|
71
75
|
stringifyError,
|
|
72
76
|
VERSION,
|
|
73
77
|
} from "@/utils";
|
|
74
|
-
import {
|
|
75
|
-
wrapJsNativeDatabase,
|
|
76
|
-
type JsNativeDatabaseLike,
|
|
77
|
-
} from "@/db/native-database";
|
|
78
78
|
import { logger } from "./log";
|
|
79
79
|
|
|
80
80
|
const ENVOY_SSE_PING_INTERVAL = 1000;
|
|
@@ -88,13 +88,13 @@ const REMOTE_ACK_HOOK_QUERY_PARAM = "__rivetkitAckHook";
|
|
|
88
88
|
//
|
|
89
89
|
// See engine/packages/pegboard-gateway/src/shared_state.rs
|
|
90
90
|
// (HWS_MESSAGE_ACK_TIMEOUT)
|
|
91
|
-
const
|
|
91
|
+
const _CONN_MESSAGE_ACK_DEADLINE = 5_000;
|
|
92
92
|
|
|
93
93
|
// Force saveState when cumulative message size reaches this threshold (0.5 MB)
|
|
94
94
|
//
|
|
95
95
|
// See engine/packages/pegboard-gateway/src/shared_state.rs
|
|
96
96
|
// (HWS_MAX_PENDING_MSGS_SIZE_PER_REQ)
|
|
97
|
-
const
|
|
97
|
+
const _CONN_BUFFERED_MESSAGE_SIZE_THRESHOLD = 500_000;
|
|
98
98
|
|
|
99
99
|
interface ActorHandler {
|
|
100
100
|
actor?: AnyActorInstance;
|
|
@@ -144,7 +144,6 @@ export type DriverContext = {};
|
|
|
144
144
|
|
|
145
145
|
export class EngineActorDriver implements ActorDriver {
|
|
146
146
|
#config: RegistryConfig;
|
|
147
|
-
#engineClient: EngineControlClient;
|
|
148
147
|
#inlineClient: Client<any>;
|
|
149
148
|
#envoy: EnvoyHandle;
|
|
150
149
|
#actors: Map<string, ActorHandler> = new Map();
|
|
@@ -161,15 +160,6 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
161
160
|
string,
|
|
162
161
|
HibernatableRunnerWebSocketBinding
|
|
163
162
|
>();
|
|
164
|
-
#hwsMessageIndex = new Map<
|
|
165
|
-
string,
|
|
166
|
-
{
|
|
167
|
-
serverMessageIndex: number;
|
|
168
|
-
bufferedMessageSize: number;
|
|
169
|
-
pendingAckFromMessageIndex: boolean;
|
|
170
|
-
pendingAckFromBufferSize: boolean;
|
|
171
|
-
}
|
|
172
|
-
>();
|
|
173
163
|
#actorRouter: ActorRouter;
|
|
174
164
|
|
|
175
165
|
#envoyStarted: PromiseWithResolvers<void> = promiseWithResolvers((reason) =>
|
|
@@ -284,7 +274,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
284
274
|
logger().debug({
|
|
285
275
|
msg: "actor crash cleanup errored",
|
|
286
276
|
actorId,
|
|
287
|
-
|
|
277
|
+
error: stringifyError(err),
|
|
288
278
|
});
|
|
289
279
|
}
|
|
290
280
|
}
|
|
@@ -376,8 +366,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
376
366
|
requestId: ArrayBuffer,
|
|
377
367
|
): void {
|
|
378
368
|
const key = this.#hibernatableWebSocketAckKey(gatewayId, requestId);
|
|
379
|
-
const binding =
|
|
380
|
-
this.#hibernatableRunnerWebSocketBindings.get(key);
|
|
369
|
+
const binding = this.#hibernatableRunnerWebSocketBindings.get(key);
|
|
381
370
|
if (!binding) {
|
|
382
371
|
return;
|
|
383
372
|
}
|
|
@@ -397,8 +386,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
397
386
|
requestId: ArrayBuffer,
|
|
398
387
|
): void {
|
|
399
388
|
const key = this.#hibernatableWebSocketAckKey(gatewayId, requestId);
|
|
400
|
-
const binding =
|
|
401
|
-
this.#hibernatableRunnerWebSocketBindings.get(key);
|
|
389
|
+
const binding = this.#hibernatableRunnerWebSocketBindings.get(key);
|
|
402
390
|
binding?.detach?.();
|
|
403
391
|
this.#hibernatableRunnerWebSocketBindings.delete(key);
|
|
404
392
|
}
|
|
@@ -585,7 +573,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
585
573
|
return handler;
|
|
586
574
|
}
|
|
587
575
|
|
|
588
|
-
getContext(
|
|
576
|
+
getContext(_actorId: string): DriverContext {
|
|
589
577
|
return {};
|
|
590
578
|
}
|
|
591
579
|
|
|
@@ -1140,7 +1128,10 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1140
1128
|
actorId: binding.actorId,
|
|
1141
1129
|
error: stringifyError(error),
|
|
1142
1130
|
});
|
|
1143
|
-
binding.websocket.close(
|
|
1131
|
+
binding.websocket.close(
|
|
1132
|
+
1011,
|
|
1133
|
+
"dynamic.websocket_forward_failed",
|
|
1134
|
+
);
|
|
1144
1135
|
});
|
|
1145
1136
|
};
|
|
1146
1137
|
const onClose = (event: CloseEvent) => {
|
|
@@ -1270,7 +1261,10 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1270
1261
|
msg: "dynamic runtime websocket binding is missing after restore",
|
|
1271
1262
|
actorId: binding.actorId,
|
|
1272
1263
|
});
|
|
1273
|
-
binding.websocket.close(
|
|
1264
|
+
binding.websocket.close(
|
|
1265
|
+
1011,
|
|
1266
|
+
"dynamic.websocket_forward_failed",
|
|
1267
|
+
);
|
|
1274
1268
|
return;
|
|
1275
1269
|
}
|
|
1276
1270
|
|
|
@@ -1286,7 +1280,10 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1286
1280
|
actorId: binding.actorId,
|
|
1287
1281
|
error: stringifyError(error),
|
|
1288
1282
|
});
|
|
1289
|
-
binding.websocket.close(
|
|
1283
|
+
binding.websocket.close(
|
|
1284
|
+
1011,
|
|
1285
|
+
"dynamic.websocket_forward_failed",
|
|
1286
|
+
);
|
|
1290
1287
|
});
|
|
1291
1288
|
};
|
|
1292
1289
|
const onClose = (event: CloseEvent) => {
|
|
@@ -1357,7 +1354,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1357
1354
|
logger().warn({
|
|
1358
1355
|
msg: "failed to rebind dynamic hibernatable runner websocket",
|
|
1359
1356
|
actorId,
|
|
1360
|
-
|
|
1357
|
+
error: stringifyError(result.reason),
|
|
1361
1358
|
});
|
|
1362
1359
|
}
|
|
1363
1360
|
}
|
|
@@ -1380,7 +1377,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1380
1377
|
logger().warn({
|
|
1381
1378
|
msg: "failed to rebind hibernatable connect socket",
|
|
1382
1379
|
actorId,
|
|
1383
|
-
|
|
1380
|
+
error: stringifyError(result.reason),
|
|
1384
1381
|
});
|
|
1385
1382
|
}
|
|
1386
1383
|
}
|
|
@@ -1640,7 +1637,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1640
1637
|
logger().warn({
|
|
1641
1638
|
msg: "failed to restore dynamic hibernating requests after actor start",
|
|
1642
1639
|
actorId,
|
|
1643
|
-
|
|
1640
|
+
error: stringifyError(error),
|
|
1644
1641
|
});
|
|
1645
1642
|
}
|
|
1646
1643
|
} else if (isStaticActorDefinition(definition)) {
|
|
@@ -1707,7 +1704,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1707
1704
|
logger().debug({
|
|
1708
1705
|
msg: "failed to dispose dynamic runtime after actor start failure",
|
|
1709
1706
|
actorId,
|
|
1710
|
-
|
|
1707
|
+
error: stringifyError(disposeError),
|
|
1711
1708
|
});
|
|
1712
1709
|
}
|
|
1713
1710
|
this.#dynamicRuntimes.delete(actorId);
|
|
@@ -1730,7 +1727,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1730
1727
|
actorId,
|
|
1731
1728
|
name,
|
|
1732
1729
|
key,
|
|
1733
|
-
|
|
1730
|
+
error: stringifyError(error),
|
|
1734
1731
|
});
|
|
1735
1732
|
|
|
1736
1733
|
try {
|
|
@@ -1739,7 +1736,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1739
1736
|
logger().debug({
|
|
1740
1737
|
msg: "failed to stop actor after start failure",
|
|
1741
1738
|
actorId,
|
|
1742
|
-
|
|
1739
|
+
error: stringifyError(stopError),
|
|
1743
1740
|
});
|
|
1744
1741
|
}
|
|
1745
1742
|
}
|
|
@@ -1786,7 +1783,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1786
1783
|
logger().debug({
|
|
1787
1784
|
msg: "actor start failed during stop, cleaning up handler",
|
|
1788
1785
|
actorId,
|
|
1789
|
-
|
|
1786
|
+
error: stringifyError(err),
|
|
1790
1787
|
});
|
|
1791
1788
|
}
|
|
1792
1789
|
}
|
|
@@ -1804,7 +1801,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1804
1801
|
} catch (err) {
|
|
1805
1802
|
logger().error({
|
|
1806
1803
|
msg: "error in onStop, proceeding with removing actor",
|
|
1807
|
-
|
|
1804
|
+
error: stringifyError(err),
|
|
1808
1805
|
});
|
|
1809
1806
|
}
|
|
1810
1807
|
}
|
|
@@ -1989,8 +1986,11 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
1989
1986
|
isHibernatable,
|
|
1990
1987
|
isRestoringHibernatable,
|
|
1991
1988
|
);
|
|
1992
|
-
} catch (
|
|
1993
|
-
logger().error({
|
|
1989
|
+
} catch (error) {
|
|
1990
|
+
logger().error({
|
|
1991
|
+
msg: "building websocket handlers errored",
|
|
1992
|
+
error,
|
|
1993
|
+
});
|
|
1994
1994
|
websocketRaw.close(1011, "ws.route_error");
|
|
1995
1995
|
return;
|
|
1996
1996
|
}
|
|
@@ -2005,7 +2005,7 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
2005
2005
|
// Get connection and actor from wsHandler (may be undefined for inspector endpoint)
|
|
2006
2006
|
const conn = wsHandler.conn;
|
|
2007
2007
|
const actor = wsHandler.actor;
|
|
2008
|
-
const
|
|
2008
|
+
const _connStateManager = conn?.[CONN_STATE_MANAGER_SYMBOL];
|
|
2009
2009
|
|
|
2010
2010
|
// Bind event listeners to Hono WebSocket handlers
|
|
2011
2011
|
//
|
|
@@ -2044,16 +2044,15 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
2044
2044
|
|
|
2045
2045
|
const currentActor = this.#actors.get(actorId)?.actor;
|
|
2046
2046
|
const actorForDispatch =
|
|
2047
|
-
currentActor &&
|
|
2048
|
-
isStaticActorInstance(currentActor)
|
|
2047
|
+
currentActor && isStaticActorInstance(currentActor)
|
|
2049
2048
|
? currentActor
|
|
2050
2049
|
: actor;
|
|
2051
2050
|
const connForDispatch =
|
|
2052
2051
|
isHibernatable && actorForDispatch
|
|
2053
|
-
? actorForDispatch.connectionManager.findHibernatableConn(
|
|
2052
|
+
? (actorForDispatch.connectionManager.findHibernatableConn(
|
|
2054
2053
|
gatewayIdBuf,
|
|
2055
2054
|
requestIdBuf,
|
|
2056
|
-
) ?? conn
|
|
2055
|
+
) ?? conn)
|
|
2057
2056
|
: conn;
|
|
2058
2057
|
|
|
2059
2058
|
if (actorForDispatch?.isStopping) {
|
|
@@ -2063,7 +2062,10 @@ export class EngineActorDriver implements ActorDriver {
|
|
|
2063
2062
|
actorId: actorForDispatch?.id,
|
|
2064
2063
|
messageIndex: event.rivetMessageIndex,
|
|
2065
2064
|
});
|
|
2066
|
-
if (
|
|
2065
|
+
if (
|
|
2066
|
+
!isRawWebSocketPath &&
|
|
2067
|
+
websocket.readyState !== websocket.CLOSED
|
|
2068
|
+
) {
|
|
2067
2069
|
websocket.close(1011, "actor.stopping");
|
|
2068
2070
|
}
|
|
2069
2071
|
return;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DynamicActorIsolateRuntime } from "./isolate-runtime";
|
|
2
|
+
|
|
3
|
+
export class DynamicActorInstance {
|
|
4
|
+
constructor(
|
|
5
|
+
public readonly id: string,
|
|
6
|
+
private readonly runtime: DynamicActorIsolateRuntime,
|
|
7
|
+
) {}
|
|
8
|
+
|
|
9
|
+
get isStopping(): boolean {
|
|
10
|
+
return this.runtime.isStopping;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async onStop(mode: "sleep" | "destroy"): Promise<void> {
|
|
14
|
+
await this.runtime.stop(mode);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async onAlarm(): Promise<void> {
|
|
18
|
+
await this.runtime.onAlarm();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async cleanupPersistedConnections(reason?: string): Promise<number> {
|
|
22
|
+
return await this.runtime.cleanupPersistedConnections(reason);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async getHibernatingWebSockets() {
|
|
26
|
+
return await this.runtime.getHibernatingWebSockets();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getHibernatingWebSocketMetadata() {
|
|
30
|
+
return this.runtime.getHibernatingWebSocketMetadata();
|
|
31
|
+
}
|
|
32
|
+
}
|