rivetkit 2.3.0-rc.8 → 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 +481 -74
- package/dist/browser/client.js +174 -148
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +47 -18
- 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 +2160 -2086
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +479 -73
- package/dist/tsup/agent-os/index.d.ts +479 -73
- package/dist/tsup/agent-os/index.js +2160 -2086
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-KY3CERZR.js → chunk-2OTRTA3J.js} +7 -21
- package/dist/tsup/chunk-2OTRTA3J.js.map +1 -0
- package/dist/tsup/{chunk-HGW6PBWR.cjs → chunk-3677IIOV.cjs} +11 -25
- package/dist/tsup/chunk-3677IIOV.cjs.map +1 -0
- package/dist/tsup/{chunk-OT7FF6GB.cjs → chunk-47HHIEXH.cjs} +24 -9
- package/dist/tsup/chunk-47HHIEXH.cjs.map +1 -0
- package/dist/tsup/{chunk-EMFKMVJR.js → chunk-4JDSFJS5.js} +69 -58
- package/dist/tsup/chunk-4JDSFJS5.js.map +1 -0
- package/dist/tsup/{chunk-7HLFSAJP.cjs → chunk-7QKCIVAY.cjs} +225 -214
- package/dist/tsup/chunk-7QKCIVAY.cjs.map +1 -0
- package/dist/tsup/{chunk-AWTPTUQ7.cjs → chunk-B6VUNZUD.cjs} +10 -10
- package/dist/tsup/{chunk-AWTPTUQ7.cjs.map → chunk-B6VUNZUD.cjs.map} +1 -1
- package/dist/tsup/{chunk-D3T3ZBSY.js → chunk-BEI24WTI.js} +2 -2
- package/dist/tsup/{chunk-TMLOKTRB.js → chunk-BRP62GZC.js} +1 -1
- package/dist/tsup/chunk-BRP62GZC.js.map +1 -0
- package/dist/tsup/{chunk-D5G75T7J.js → chunk-DPIMKYNB.js} +61 -2
- package/dist/tsup/chunk-DPIMKYNB.js.map +1 -0
- package/dist/tsup/{chunk-BATTOVHF.cjs → chunk-DXXJPH55.cjs} +40 -13
- 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-4BPKKZJO.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-63WNTDRC.cjs → chunk-KORQB2IR.cjs} +1 -1
- package/dist/tsup/{chunk-63WNTDRC.cjs.map → chunk-KORQB2IR.cjs.map} +1 -1
- package/dist/tsup/{chunk-6TQSSJ4F.cjs → chunk-LVTBW2RE.cjs} +3 -3
- package/dist/tsup/{chunk-6TQSSJ4F.cjs.map → chunk-LVTBW2RE.cjs.map} +1 -1
- package/dist/tsup/{chunk-4JU3IPG2.js → chunk-MEHBWPLJ.js} +6 -6
- package/dist/tsup/chunk-MEHBWPLJ.js.map +1 -0
- package/dist/tsup/{chunk-SRNOPUC6.cjs → chunk-NIY3RSPX.cjs} +62 -3
- package/dist/tsup/chunk-NIY3RSPX.cjs.map +1 -0
- package/dist/tsup/{chunk-UZXQEGVJ.js → chunk-P2GNQ4RN.js} +4 -4
- package/dist/tsup/{chunk-UZXQEGVJ.js.map → chunk-P2GNQ4RN.js.map} +1 -1
- package/dist/tsup/{chunk-VUGENVIK.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-GBG63SUG.js → chunk-VTTFNQQI.js} +32 -5
- 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-Ak1lv4gF.d.ts → config-BxWAw3iH.d.ts} +512 -27
- package/dist/tsup/{config-DU_xj4qZ.d.cts → config-CZQQ-mso.d.cts} +512 -27
- package/dist/tsup/{config-CxjGYf4K.d.ts → config-D49x8NpL.d.cts} +1 -2
- package/dist/tsup/{config-CxjGYf4K.d.cts → config-D49x8NpL.d.ts} +1 -2
- package/dist/tsup/{context-DAAp4Lpg.d.ts → context-Bw7xq8w3.d.cts} +8 -8
- package/dist/tsup/{context-Dt_L55q8.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 +615 -348
- 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 +511 -244
- 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 +279 -279
- 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 +380 -380
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +29 -9
- package/src/actor/config.ts +156 -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 +8 -2
- 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/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 +11 -11
- package/src/client/actor-handle.ts +69 -52
- 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 -4
- package/src/client/raw-utils.ts +8 -6
- package/src/client/resolve-gateway-target.ts +1 -1
- package/src/client/utils.ts +2 -6
- 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 +13 -17
- package/src/common/engine.ts +28 -1
- package/src/common/eventsource.ts +1 -1
- package/src/common/inline-websocket-adapter.ts +3 -2
- package/src/common/router.ts +13 -17
- package/src/common/utils.ts +1 -2
- 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 +48 -46
- 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 +5 -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 +5 -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 +226 -83
- package/src/registry/napi-runtime.ts +46 -12
- package/src/registry/native-validation.ts +10 -12
- package/src/registry/native.ts +307 -164
- package/src/registry/process-metrics.ts +90 -23
- package/src/registry/runtime.ts +53 -6
- package/src/registry/wasm-runtime.ts +30 -3
- package/src/serde.ts +1 -1
- 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 +30 -29
- package/src/workflow/driver.ts +4 -6
- package/src/workflow/inspector.ts +2 -2
- 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-4BPKKZJO.cjs.map +0 -1
- package/dist/tsup/chunk-4JU3IPG2.js.map +0 -1
- package/dist/tsup/chunk-7HLFSAJP.cjs.map +0 -1
- package/dist/tsup/chunk-BATTOVHF.cjs.map +0 -1
- package/dist/tsup/chunk-D5G75T7J.js.map +0 -1
- package/dist/tsup/chunk-EMFKMVJR.js.map +0 -1
- package/dist/tsup/chunk-GBG63SUG.js.map +0 -1
- package/dist/tsup/chunk-HGW6PBWR.cjs.map +0 -1
- package/dist/tsup/chunk-KY3CERZR.js.map +0 -1
- package/dist/tsup/chunk-OT7FF6GB.cjs.map +0 -1
- package/dist/tsup/chunk-PCBNKI2J.js.map +0 -1
- package/dist/tsup/chunk-SRNOPUC6.cjs.map +0 -1
- package/dist/tsup/chunk-TMLOKTRB.js.map +0 -1
- package/dist/tsup/chunk-VUGENVIK.js.map +0 -1
- package/dist/tsup/process-metrics-NW754INA.js +0 -118
- package/dist/tsup/process-metrics-NW754INA.js.map +0 -1
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs +0 -118
- package/dist/tsup/process-metrics-TYAGKCEJ.cjs.map +0 -1
- /package/dist/tsup/{chunk-D3T3ZBSY.js.map → chunk-BEI24WTI.js.map} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AnyActorDefinition } from "@/actor/definition";
|
|
2
2
|
import type { ActorSpecifier } from "@/actor/errors";
|
|
3
|
-
import type { Encoding } from "@/common/encoding";
|
|
4
3
|
import {
|
|
5
4
|
HEADER_CONN_PARAMS,
|
|
6
5
|
HEADER_ENCODING,
|
|
@@ -12,7 +11,6 @@ import {
|
|
|
12
11
|
HTTP_ACTION_RESPONSE_VERSIONED,
|
|
13
12
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
14
13
|
} from "@/common/client-protocol-versioned";
|
|
15
|
-
import { AsyncMutex } from "@/common/database/shared";
|
|
16
14
|
import {
|
|
17
15
|
type HttpActionRequest as HttpActionRequestJson,
|
|
18
16
|
HttpActionRequestSchema,
|
|
@@ -21,17 +19,22 @@ import {
|
|
|
21
19
|
type HttpResponseError as HttpResponseErrorJson,
|
|
22
20
|
HttpResponseErrorSchema,
|
|
23
21
|
} from "@/common/client-protocol-zod";
|
|
22
|
+
import { AsyncMutex } from "@/common/database/shared";
|
|
23
|
+
import type { Encoding, JsonCompatValue } from "@/common/encoding";
|
|
24
24
|
import { deconstructError } from "@/common/utils";
|
|
25
25
|
import type { EngineControlClient } from "@/engine-client/driver";
|
|
26
|
-
import
|
|
27
|
-
|
|
26
|
+
import {
|
|
27
|
+
decodeCborCompat,
|
|
28
|
+
deserializeWithEncoding,
|
|
29
|
+
encodeCborCompat,
|
|
30
|
+
} from "@/serde";
|
|
28
31
|
import { bufferToArrayBuffer } from "@/utils";
|
|
29
32
|
import type {
|
|
30
33
|
ActorActionOptions,
|
|
31
34
|
ActorConnectOptions,
|
|
32
35
|
ActorDefinitionActions,
|
|
33
|
-
ActorFetchInit,
|
|
34
36
|
ActorDefinitionQueueSend,
|
|
37
|
+
ActorFetchInit,
|
|
35
38
|
ActorGatewayOptions,
|
|
36
39
|
ActorWebSocketOptions,
|
|
37
40
|
} from "./actor-common";
|
|
@@ -148,7 +151,8 @@ export class ActorHandleRaw {
|
|
|
148
151
|
useQueryTarget,
|
|
149
152
|
gatewayOptions,
|
|
150
153
|
);
|
|
151
|
-
actorId =
|
|
154
|
+
actorId =
|
|
155
|
+
"directId" in target ? target.directId : undefined;
|
|
152
156
|
|
|
153
157
|
return await createQueueSender({
|
|
154
158
|
encoding: this.#encoding,
|
|
@@ -162,10 +166,8 @@ export class ActorHandleRaw {
|
|
|
162
166
|
},
|
|
163
167
|
}).send(name, body, options as any);
|
|
164
168
|
} catch (err) {
|
|
165
|
-
const { group, code, message, metadata, actor } =
|
|
166
|
-
err,
|
|
167
|
-
true,
|
|
168
|
-
);
|
|
169
|
+
const { group, code, message, metadata, actor } =
|
|
170
|
+
deconstructError(err, true);
|
|
169
171
|
|
|
170
172
|
if (
|
|
171
173
|
this.#shouldRetryQueueDispatchOverload(
|
|
@@ -208,19 +210,25 @@ export class ActorHandleRaw {
|
|
|
208
210
|
continue;
|
|
209
211
|
}
|
|
210
212
|
|
|
211
|
-
const invalidated = this.#invalidateResolvedActorId(
|
|
213
|
+
const invalidated = this.#invalidateResolvedActorId(
|
|
214
|
+
group,
|
|
215
|
+
code,
|
|
216
|
+
);
|
|
212
217
|
if (invalidated && attempt < maxAttempts - 1) {
|
|
213
218
|
useQueryTarget =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
219
|
+
code === "starting" ||
|
|
220
|
+
code === "stopping" ||
|
|
221
|
+
code.startsWith("destroyed_");
|
|
217
222
|
if (useQueryTarget) {
|
|
218
223
|
await this.#waitForRetryWindow();
|
|
219
224
|
}
|
|
220
225
|
continue;
|
|
221
226
|
}
|
|
222
227
|
|
|
223
|
-
throw new ActorError(group, code, message, {
|
|
228
|
+
throw new ActorError(group, code, message, {
|
|
229
|
+
metadata,
|
|
230
|
+
actor,
|
|
231
|
+
});
|
|
224
232
|
}
|
|
225
233
|
}
|
|
226
234
|
|
|
@@ -235,13 +243,12 @@ export class ActorHandleRaw {
|
|
|
235
243
|
* @template Args - The type of arguments to pass to the action function.
|
|
236
244
|
* @template Response - The type of the response returned by the action function.
|
|
237
245
|
*/
|
|
238
|
-
async action<
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
} & ActorActionOptions): Promise<Response> {
|
|
246
|
+
async action<Args extends Array<unknown> = unknown[], Response = unknown>(
|
|
247
|
+
opts: {
|
|
248
|
+
name: string;
|
|
249
|
+
args: Args;
|
|
250
|
+
} & ActorActionOptions,
|
|
251
|
+
): Promise<Response> {
|
|
245
252
|
if (
|
|
246
253
|
typeof opts === "string" ||
|
|
247
254
|
typeof opts !== "object" ||
|
|
@@ -260,10 +267,12 @@ export class ActorHandleRaw {
|
|
|
260
267
|
return await retryOnLifecycleBoundary(run, { signal: opts.signal });
|
|
261
268
|
}
|
|
262
269
|
|
|
263
|
-
async #sendActionNow(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
270
|
+
async #sendActionNow(
|
|
271
|
+
opts: {
|
|
272
|
+
name: string;
|
|
273
|
+
args: unknown[];
|
|
274
|
+
} & ActorActionOptions,
|
|
275
|
+
): Promise<unknown> {
|
|
267
276
|
const maxAttempts = this.#getDynamicQueryMaxAttempts();
|
|
268
277
|
let useQueryTarget = false;
|
|
269
278
|
const gatewayOptions = resolveActorGatewayOptions(
|
|
@@ -326,16 +335,20 @@ export class ActorHandleRaw {
|
|
|
326
335
|
requestVersion: CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
327
336
|
requestVersionedDataHandler: HTTP_ACTION_REQUEST_VERSIONED,
|
|
328
337
|
responseVersion: CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
329
|
-
responseVersionedDataHandler:
|
|
338
|
+
responseVersionedDataHandler:
|
|
339
|
+
HTTP_ACTION_RESPONSE_VERSIONED,
|
|
330
340
|
requestZodSchema: HttpActionRequestSchema,
|
|
331
341
|
responseZodSchema: HttpActionResponseSchema,
|
|
332
342
|
requestToJson: (args): HttpActionRequestJson => ({
|
|
333
343
|
args,
|
|
334
344
|
}),
|
|
335
345
|
requestToBare: (args): protocol.HttpActionRequest => ({
|
|
336
|
-
args: bufferToArrayBuffer(
|
|
346
|
+
args: bufferToArrayBuffer(
|
|
347
|
+
encodeCborCompat(args as JsonCompatValue),
|
|
348
|
+
),
|
|
337
349
|
}),
|
|
338
|
-
responseFromJson: (json): Response =>
|
|
350
|
+
responseFromJson: (json): Response =>
|
|
351
|
+
json.output as Response,
|
|
339
352
|
responseFromBare: (bare): Response =>
|
|
340
353
|
decodeCborCompat(new Uint8Array(bare.output)),
|
|
341
354
|
});
|
|
@@ -344,10 +357,8 @@ export class ActorHandleRaw {
|
|
|
344
357
|
}
|
|
345
358
|
return output;
|
|
346
359
|
} catch (err) {
|
|
347
|
-
const { group, code, message, metadata, actor } =
|
|
348
|
-
err,
|
|
349
|
-
true,
|
|
350
|
-
);
|
|
360
|
+
const { group, code, message, metadata, actor } =
|
|
361
|
+
deconstructError(err, true);
|
|
351
362
|
|
|
352
363
|
if (
|
|
353
364
|
await this.#shouldRetrySchedulingError(
|
|
@@ -391,14 +402,19 @@ export class ActorHandleRaw {
|
|
|
391
402
|
);
|
|
392
403
|
}
|
|
393
404
|
|
|
394
|
-
const invalidated = this.#invalidateResolvedActorId(
|
|
405
|
+
const invalidated = this.#invalidateResolvedActorId(
|
|
406
|
+
group,
|
|
407
|
+
code,
|
|
408
|
+
);
|
|
395
409
|
if (invalidated && attempt < maxAttempts - 1) {
|
|
396
410
|
if (
|
|
397
411
|
group === "actor" &&
|
|
398
412
|
(code === "starting" || code === "stopping")
|
|
399
413
|
) {
|
|
400
414
|
useQueryTarget = true;
|
|
401
|
-
await new Promise((resolve) =>
|
|
415
|
+
await new Promise((resolve) =>
|
|
416
|
+
setTimeout(resolve, 100),
|
|
417
|
+
);
|
|
402
418
|
}
|
|
403
419
|
continue;
|
|
404
420
|
}
|
|
@@ -663,10 +679,8 @@ export class ActorHandleRaw {
|
|
|
663
679
|
}
|
|
664
680
|
return response;
|
|
665
681
|
} catch (err) {
|
|
666
|
-
const { group, code, message, metadata, actor } =
|
|
667
|
-
err,
|
|
668
|
-
true,
|
|
669
|
-
);
|
|
682
|
+
const { group, code, message, metadata, actor } =
|
|
683
|
+
deconstructError(err, true);
|
|
670
684
|
|
|
671
685
|
if (
|
|
672
686
|
await this.#shouldRetrySchedulingError(
|
|
@@ -696,12 +710,15 @@ export class ActorHandleRaw {
|
|
|
696
710
|
continue;
|
|
697
711
|
}
|
|
698
712
|
|
|
699
|
-
const invalidated = this.#invalidateResolvedActorId(
|
|
713
|
+
const invalidated = this.#invalidateResolvedActorId(
|
|
714
|
+
group,
|
|
715
|
+
code,
|
|
716
|
+
);
|
|
700
717
|
if (invalidated && attempt < maxAttempts - 1) {
|
|
701
718
|
useQueryTarget =
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
719
|
+
code === "starting" ||
|
|
720
|
+
code === "stopping" ||
|
|
721
|
+
code.startsWith("destroyed_");
|
|
705
722
|
if (useQueryTarget) {
|
|
706
723
|
await this.#waitForRetryWindow();
|
|
707
724
|
}
|
|
@@ -720,13 +737,10 @@ export class ActorHandleRaw {
|
|
|
720
737
|
actorId: string | undefined,
|
|
721
738
|
attempt: number,
|
|
722
739
|
maxAttempts: number,
|
|
723
|
-
): Promise<
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
| null
|
|
729
|
-
> {
|
|
740
|
+
): Promise<{
|
|
741
|
+
useQueryTarget: boolean;
|
|
742
|
+
waitForRetryWindow: boolean;
|
|
743
|
+
} | null> {
|
|
730
744
|
if (response.ok || !isDynamicActorQuery(this.#actorResolutionState)) {
|
|
731
745
|
return null;
|
|
732
746
|
}
|
|
@@ -858,8 +872,9 @@ export class ActorHandleRaw {
|
|
|
858
872
|
this.#gatewayOptions,
|
|
859
873
|
options,
|
|
860
874
|
);
|
|
875
|
+
const useQueryTarget = isDynamicActorQuery(this.#actorResolutionState);
|
|
861
876
|
const target = await this.#resolveGatewayRequestTarget(
|
|
862
|
-
|
|
877
|
+
useQueryTarget,
|
|
863
878
|
gatewayOptions,
|
|
864
879
|
);
|
|
865
880
|
return await rawWebSocket(
|
|
@@ -885,7 +900,9 @@ export class ActorHandleRaw {
|
|
|
885
900
|
return target.directId;
|
|
886
901
|
}
|
|
887
902
|
|
|
888
|
-
throw new Error(
|
|
903
|
+
throw new Error(
|
|
904
|
+
"dynamic actor resolution did not produce a direct actor id",
|
|
905
|
+
);
|
|
889
906
|
}
|
|
890
907
|
|
|
891
908
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as errors from "@/actor/errors";
|
|
2
|
+
import type { ActorQuery } from "@/client/query";
|
|
2
3
|
import { stringifyError } from "@/common/utils";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type {
|
|
5
|
+
EngineControlClient,
|
|
6
|
+
GatewayTarget,
|
|
6
7
|
} from "@/engine-client/driver";
|
|
7
|
-
import type
|
|
8
|
-
import { actorSchedulingError, type ActorSchedulingError } from "./errors";
|
|
8
|
+
import { type ActorSchedulingError, actorSchedulingError } from "./errors";
|
|
9
9
|
import { logger } from "./log";
|
|
10
10
|
|
|
11
11
|
/**
|
package/src/client/errors.ts
CHANGED
|
@@ -162,6 +162,7 @@ function classifyActorError(
|
|
|
162
162
|
function isRetryableGuardGatewayHttpError(code: string): boolean {
|
|
163
163
|
return (
|
|
164
164
|
code === "service_unavailable" ||
|
|
165
|
+
code === "actor_wake_retries_exceeded" ||
|
|
165
166
|
code === "actor_stopped_while_waiting" ||
|
|
166
167
|
code === "tunnel_request_aborted" ||
|
|
167
168
|
code === "tunnel_message_timeout" ||
|
|
@@ -299,10 +300,7 @@ export async function retryOnLifecycleBoundary<T>(
|
|
|
299
300
|
break;
|
|
300
301
|
}
|
|
301
302
|
|
|
302
|
-
const delayMs = Math.min(
|
|
303
|
-
initialDelayMs * 2 ** attempt,
|
|
304
|
-
maxDelayMs,
|
|
305
|
-
);
|
|
303
|
+
const delayMs = Math.min(initialDelayMs * 2 ** attempt, maxDelayMs);
|
|
306
304
|
await waitWithSignal(delayMs, opts?.signal);
|
|
307
305
|
}
|
|
308
306
|
}
|
package/src/client/query.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
|
-
import { EncodingSchema } from "@/common/encoding";
|
|
3
2
|
import {
|
|
4
3
|
HEADER_ACTOR_ID,
|
|
5
4
|
HEADER_ACTOR_QUERY,
|
|
6
5
|
HEADER_CONN_PARAMS,
|
|
7
6
|
HEADER_ENCODING,
|
|
8
7
|
} from "@/common/actor-router-consts";
|
|
8
|
+
import { EncodingSchema } from "@/common/encoding";
|
|
9
9
|
|
|
10
10
|
// Maximum size of a key component in bytes
|
|
11
11
|
// Set to 128 bytes to allow for separators and escape characters in the full key
|
package/src/client/queue.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
HEADER_CONN_PARAMS,
|
|
3
|
+
HEADER_ENCODING,
|
|
4
|
+
} from "@/common/actor-router-consts";
|
|
3
5
|
import type * as protocol from "@/common/client-protocol";
|
|
4
6
|
import {
|
|
5
7
|
CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
@@ -12,7 +14,7 @@ import {
|
|
|
12
14
|
type HttpQueueSendResponse as HttpQueueSendResponseJson,
|
|
13
15
|
HttpQueueSendResponseSchema,
|
|
14
16
|
} from "@/common/client-protocol-zod";
|
|
15
|
-
import type { JsonCompatValue } from "@/common/encoding";
|
|
17
|
+
import type { Encoding, JsonCompatValue } from "@/common/encoding";
|
|
16
18
|
import { decodeCborCompat, encodeCborCompat } from "@/serde";
|
|
17
19
|
import { bufferToArrayBuffer } from "@/utils";
|
|
18
20
|
import { sendHttpRequest } from "./utils";
|
|
@@ -112,7 +114,9 @@ export function createQueueSender(
|
|
|
112
114
|
}),
|
|
113
115
|
requestToBare: (value): protocol.HttpQueueSendRequest => ({
|
|
114
116
|
name: value.name ?? name,
|
|
115
|
-
body: bufferToArrayBuffer(
|
|
117
|
+
body: bufferToArrayBuffer(
|
|
118
|
+
encodeCborCompat(value.body as JsonCompatValue),
|
|
119
|
+
),
|
|
116
120
|
wait: value.wait ?? false,
|
|
117
121
|
timeout:
|
|
118
122
|
value.timeout !== undefined ? BigInt(value.timeout) : null,
|
package/src/client/raw-utils.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { PATH_WEBSOCKET_PREFIX } from "@/common/actor-router-consts";
|
|
2
|
-
import { deconstructError } from "@/common/utils";
|
|
3
1
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
HEADER_CONN_PARAMS,
|
|
3
|
+
PATH_WEBSOCKET_PREFIX,
|
|
4
|
+
} from "@/common/actor-router-consts";
|
|
5
|
+
import { deconstructError } from "@/common/utils";
|
|
6
|
+
import type {
|
|
7
|
+
EngineControlClient,
|
|
8
|
+
GatewayRequestOptions,
|
|
9
|
+
GatewayTarget,
|
|
7
10
|
} from "@/engine-client/driver";
|
|
8
|
-
import { HEADER_CONN_PARAMS } from "@/common/actor-router-consts";
|
|
9
11
|
import { ActorError } from "./errors";
|
|
10
12
|
import { logger } from "./log";
|
|
11
13
|
|
package/src/client/utils.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
2
|
import type { VersionedDataHandler } from "vbare";
|
|
3
3
|
import type { z } from "zod/v4";
|
|
4
|
+
import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/common/client-protocol-versioned";
|
|
5
|
+
import { HttpResponseErrorSchema } from "@/common/client-protocol-zod";
|
|
4
6
|
import type { Encoding } from "@/common/encoding";
|
|
5
7
|
import { assertUnreachable } from "@/common/utils";
|
|
6
|
-
import { HTTP_RESPONSE_ERROR_VERSIONED } from "@/common/client-protocol-versioned";
|
|
7
|
-
import {
|
|
8
|
-
type HttpResponseError as HttpResponseErrorJson,
|
|
9
|
-
HttpResponseErrorSchema,
|
|
10
|
-
} from "@/common/client-protocol-zod";
|
|
11
8
|
import {
|
|
12
9
|
contentTypeForEncoding,
|
|
13
10
|
decodeCborCompat,
|
|
14
11
|
deserializeWithEncoding,
|
|
15
|
-
encodingIsBinary,
|
|
16
12
|
serializeWithEncoding,
|
|
17
13
|
} from "@/serde";
|
|
18
14
|
import { httpUserAgent } from "@/utils";
|
|
@@ -30,7 +30,9 @@ export function parseWebSocketProtocols(
|
|
|
30
30
|
let ackHookTokenRaw: string | undefined;
|
|
31
31
|
|
|
32
32
|
if (protocols) {
|
|
33
|
-
for (const protocol of protocols
|
|
33
|
+
for (const protocol of protocols
|
|
34
|
+
.split(",")
|
|
35
|
+
.map((value) => value.trim())) {
|
|
34
36
|
if (protocol.startsWith(WS_PROTOCOL_ENCODING)) {
|
|
35
37
|
encodingRaw = protocol.substring(WS_PROTOCOL_ENCODING.length);
|
|
36
38
|
} else if (protocol.startsWith(WS_PROTOCOL_CONN_PARAMS)) {
|