rivetkit 3.0.7 → 3.1.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 +115 -2
- package/dist/browser/client.js +145 -7
- 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/tsup/{chunk-RFJ4NNO3.js → chunk-AOBZYPOQ.js} +4 -4
- package/dist/tsup/{chunk-YWWDUC6D.cjs → chunk-AQJFKHBK.cjs} +5 -1
- package/dist/tsup/chunk-AQJFKHBK.cjs.map +1 -0
- package/dist/tsup/{chunk-U3CMQVMS.cjs → chunk-BADLJ4CM.cjs} +3 -3
- package/dist/tsup/{chunk-U3CMQVMS.cjs.map → chunk-BADLJ4CM.cjs.map} +1 -1
- package/dist/tsup/{chunk-5A2KUC5L.cjs → chunk-CUM3GALQ.cjs} +10 -10
- package/dist/tsup/{chunk-5A2KUC5L.cjs.map → chunk-CUM3GALQ.cjs.map} +1 -1
- package/dist/tsup/{chunk-S6ZMUE7Q.js → chunk-CVTQX3MI.js} +2 -2
- package/dist/tsup/{chunk-QTCX5KN3.js → chunk-F5FZ6NI4.js} +2 -2
- package/dist/tsup/{chunk-AY25XAXA.js → chunk-G3KFGH3I.js} +3 -3
- package/dist/tsup/{chunk-AY25XAXA.js.map → chunk-G3KFGH3I.js.map} +1 -1
- package/dist/tsup/{chunk-WBUHPDDM.cjs → chunk-HFE4VBQU.cjs} +2 -2
- package/dist/tsup/{chunk-WBUHPDDM.cjs.map → chunk-HFE4VBQU.cjs.map} +1 -1
- package/dist/tsup/{chunk-YO4TJ56P.js → chunk-IDJSGBVA.js} +2 -2
- package/dist/tsup/{chunk-PBIQPYE5.js → chunk-IHEO5OT3.js} +5 -1
- package/dist/tsup/chunk-IHEO5OT3.js.map +1 -0
- package/dist/tsup/{chunk-K6WETGBW.cjs → chunk-QM5MJLVC.cjs} +3 -3
- package/dist/tsup/{chunk-K6WETGBW.cjs.map → chunk-QM5MJLVC.cjs.map} +1 -1
- package/dist/tsup/{chunk-NMLZDHH2.js → chunk-RYGXJQWL.js} +2 -2
- package/dist/tsup/{chunk-HKD7AH4Z.cjs → chunk-T5YMCOWY.cjs} +286 -149
- package/dist/tsup/chunk-T5YMCOWY.cjs.map +1 -0
- package/dist/tsup/{chunk-7OXC5BQF.js → chunk-TY25ZHJV.js} +2 -2
- package/dist/tsup/{chunk-7OXC5BQF.js.map → chunk-TY25ZHJV.js.map} +1 -1
- package/dist/tsup/{chunk-YTELGNB3.cjs → chunk-UJNHLIIG.cjs} +7 -7
- package/dist/tsup/{chunk-YTELGNB3.cjs.map → chunk-UJNHLIIG.cjs.map} +1 -1
- package/dist/tsup/{chunk-YMCG4FCB.js → chunk-VCORVUP2.js} +146 -9
- package/dist/tsup/chunk-VCORVUP2.js.map +1 -0
- package/dist/tsup/{chunk-OEOODXVI.cjs → chunk-VGJXSQMF.cjs} +4 -4
- package/dist/tsup/{chunk-OEOODXVI.cjs.map → chunk-VGJXSQMF.cjs.map} +1 -1
- package/dist/tsup/{chunk-VM4SXQOC.cjs → chunk-YWWIVWBR.cjs} +3 -3
- package/dist/tsup/{chunk-VM4SXQOC.cjs.map → chunk-YWWIVWBR.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +4 -4
- 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-BDJltifk.d.cts → config-BDdeBoxX.d.cts} +117 -3
- package/dist/tsup/{config-DXC7qzme.d.ts → config-Ch-SMJ-n.d.ts} +117 -3
- package/dist/tsup/{context-DgPsVbw6.d.ts → context-B-wRuYrf.d.ts} +5 -1
- package/dist/tsup/{context-osC4Q1ax.d.cts → context-NzsxAAoN.d.cts} +5 -1
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +1 -1
- package/dist/tsup/dynamic/mod.js +1 -1
- package/dist/tsup/inspector/mod.cjs +5 -5
- package/dist/tsup/inspector/mod.js +4 -4
- package/dist/tsup/inspector/workflow.cjs +4 -4
- package/dist/tsup/inspector/workflow.js +3 -3
- package/dist/tsup/inspector-tab/mod.cjs +2 -2
- package/dist/tsup/inspector-tab/mod.d.cts +2 -2
- package/dist/tsup/inspector-tab/mod.d.ts +2 -2
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +153 -110
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +3 -3
- package/dist/tsup/mod.d.ts +3 -3
- package/dist/tsup/mod.js +49 -6
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +22 -10
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +17 -5
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +9 -9
- package/src/actor/config.ts +82 -0
- package/src/client/actor-conn.ts +43 -7
- package/src/client/client.ts +93 -0
- package/src/client/errors.ts +12 -0
- package/src/client/lifecycle-errors.ts +28 -1
- package/src/client/mod.ts +1 -0
- package/src/client/retry-budget.ts +4 -1
- package/src/common/actor-router-consts.ts +1 -0
- package/src/engine-api/actors.ts +12 -0
- package/src/engine-client/actor-http-client.ts +6 -0
- package/src/engine-client/actor-websocket-client.ts +25 -1
- package/src/engine-client/api-endpoints.ts +16 -0
- package/src/engine-client/driver.ts +12 -0
- package/src/engine-client/mod.ts +30 -0
- package/src/registry/napi-runtime.ts +8 -0
- package/src/registry/native.ts +49 -0
- package/src/registry/runtime.ts +11 -0
- package/src/registry/wasm-runtime.ts +9 -0
- package/src/workflow/context.ts +17 -0
- package/dist/tsup/chunk-HKD7AH4Z.cjs.map +0 -1
- package/dist/tsup/chunk-PBIQPYE5.js.map +0 -1
- package/dist/tsup/chunk-YMCG4FCB.js.map +0 -1
- package/dist/tsup/chunk-YWWDUC6D.cjs.map +0 -1
- /package/dist/tsup/{chunk-RFJ4NNO3.js.map → chunk-AOBZYPOQ.js.map} +0 -0
- /package/dist/tsup/{chunk-S6ZMUE7Q.js.map → chunk-CVTQX3MI.js.map} +0 -0
- /package/dist/tsup/{chunk-QTCX5KN3.js.map → chunk-F5FZ6NI4.js.map} +0 -0
- /package/dist/tsup/{chunk-YO4TJ56P.js.map → chunk-IDJSGBVA.js.map} +0 -0
- /package/dist/tsup/{chunk-NMLZDHH2.js.map → chunk-RYGXJQWL.js.map} +0 -0
|
@@ -9,7 +9,7 @@ var _chunkKVFIONKQcjs = require('./chunk-KVFIONKQ.cjs');
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkQM5MJLVCcjs = require('./chunk-QM5MJLVC.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -36,7 +36,7 @@ var _chunkK6WETGBWcjs = require('./chunk-K6WETGBW.cjs');
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var _chunkHFE4VBQUcjs = require('./chunk-HFE4VBQU.cjs');
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
@@ -67,6 +67,7 @@ var HEADER_RIVET_SKIP_READY_WAIT = "x-rivet-skip-ready-wait";
|
|
|
67
67
|
var WS_PROTOCOL_STANDARD = "rivet";
|
|
68
68
|
var WS_PROTOCOL_TARGET = "rivet_target.";
|
|
69
69
|
var WS_PROTOCOL_ACTOR = "rivet_actor.";
|
|
70
|
+
var WS_PROTOCOL_NAMESPACE = "rivet_namespace.";
|
|
70
71
|
var WS_PROTOCOL_ENCODING = "rivet_encoding.";
|
|
71
72
|
var WS_PROTOCOL_CONN_PARAMS = "rivet_conn_params.";
|
|
72
73
|
var WS_PROTOCOL_TOKEN = "rivet_token.";
|
|
@@ -114,6 +115,12 @@ var ActorConnDisposed = class extends ActorClientError {
|
|
|
114
115
|
function isSchedulingError(group, code) {
|
|
115
116
|
return group === "guard" && (code === "actor_ready_timeout" || code === "actor_runner_failed");
|
|
116
117
|
}
|
|
118
|
+
function isActorDestroyed(group, code) {
|
|
119
|
+
return group === "actor" && code === "destroyed";
|
|
120
|
+
}
|
|
121
|
+
function isActorNotFound(group, code) {
|
|
122
|
+
return group === "actor" && code === "not_found";
|
|
123
|
+
}
|
|
117
124
|
function actorSchedulingError(group, code, actorId, details, rayId) {
|
|
118
125
|
return new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
119
126
|
group,
|
|
@@ -2132,7 +2139,7 @@ async function checkForSchedulingError(group, code, actorId, query, driver, rayI
|
|
|
2132
2139
|
try {
|
|
2133
2140
|
const actor = await driver.getForId({ name, actorId });
|
|
2134
2141
|
if (actor == null ? void 0 : actor.error) {
|
|
2135
|
-
|
|
2142
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).info({
|
|
2136
2143
|
msg: "found actor scheduling error",
|
|
2137
2144
|
actorId,
|
|
2138
2145
|
error: actor.error
|
|
@@ -2146,10 +2153,10 @@ async function checkForSchedulingError(group, code, actorId, query, driver, rayI
|
|
|
2146
2153
|
);
|
|
2147
2154
|
}
|
|
2148
2155
|
} catch (err) {
|
|
2149
|
-
|
|
2156
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
2150
2157
|
msg: "failed to fetch actor details for scheduling error check",
|
|
2151
2158
|
actorId,
|
|
2152
|
-
error:
|
|
2159
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
2153
2160
|
});
|
|
2154
2161
|
}
|
|
2155
2162
|
return null;
|
|
@@ -2222,7 +2229,10 @@ function retryAfterMs(error) {
|
|
|
2222
2229
|
return typeof hint === "number" && hint >= 0 ? hint : void 0;
|
|
2223
2230
|
}
|
|
2224
2231
|
function retryDelayMs(attempt, opts) {
|
|
2225
|
-
const backoff = Math.min(
|
|
2232
|
+
const backoff = Math.min(
|
|
2233
|
+
opts.initialDelayMs * 2 ** attempt,
|
|
2234
|
+
opts.maxDelayMs
|
|
2235
|
+
);
|
|
2226
2236
|
const jittered = backoff / 2 + Math.random() * (backoff / 2);
|
|
2227
2237
|
return Math.max(jittered, _nullishCoalesce(opts.hintMs, () => ( 0)));
|
|
2228
2238
|
}
|
|
@@ -2409,11 +2419,25 @@ async function waitWithSignal(ms, signal) {
|
|
|
2409
2419
|
signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
|
|
2410
2420
|
});
|
|
2411
2421
|
}
|
|
2422
|
+
function isRetryableForkRefusal(error) {
|
|
2423
|
+
if (!(error instanceof _chunkMGI2VVF6cjs.RivetError)) {
|
|
2424
|
+
return false;
|
|
2425
|
+
}
|
|
2426
|
+
if (error.group === "actor" && error.code === "fork_unavailable") {
|
|
2427
|
+
return true;
|
|
2428
|
+
}
|
|
2429
|
+
if (error.group === "guard" && error.code === "service_unavailable") {
|
|
2430
|
+
const metadata = error.metadata;
|
|
2431
|
+
return (metadata == null ? void 0 : metadata.reason) === "actor_moving";
|
|
2432
|
+
}
|
|
2433
|
+
return false;
|
|
2434
|
+
}
|
|
2412
2435
|
async function retryOnLifecycleBoundary(run, opts) {
|
|
2413
2436
|
var _a;
|
|
2414
2437
|
const maxAttempts = _nullishCoalesce((opts == null ? void 0 : opts.maxAttempts), () => ( 5));
|
|
2415
2438
|
const initialDelayMs = _nullishCoalesce((opts == null ? void 0 : opts.initialDelayMs), () => ( 25));
|
|
2416
2439
|
const maxDelayMs = _nullishCoalesce((opts == null ? void 0 : opts.maxDelayMs), () => ( 200));
|
|
2440
|
+
const isRetryable = _nullishCoalesce((opts == null ? void 0 : opts.isRetryable), () => ( isRetryableLifecycleRequestError));
|
|
2417
2441
|
(_a = opts == null ? void 0 : opts.budget) == null ? void 0 : _a.deposit();
|
|
2418
2442
|
let lastError;
|
|
2419
2443
|
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
@@ -2421,7 +2445,7 @@ async function retryOnLifecycleBoundary(run, opts) {
|
|
|
2421
2445
|
try {
|
|
2422
2446
|
return await run();
|
|
2423
2447
|
} catch (error) {
|
|
2424
|
-
if (!
|
|
2448
|
+
if (!isRetryable(error)) {
|
|
2425
2449
|
throw error;
|
|
2426
2450
|
}
|
|
2427
2451
|
lastError = error;
|
|
@@ -2533,7 +2557,7 @@ function parseWebSocketCloseReason(reason) {
|
|
|
2533
2557
|
const [mainPart, suffix] = reason.split("#");
|
|
2534
2558
|
const [group, code] = mainPart.split(".");
|
|
2535
2559
|
if (!group || !code) {
|
|
2536
|
-
|
|
2560
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({ msg: "failed to parse close reason", reason });
|
|
2537
2561
|
return void 0;
|
|
2538
2562
|
}
|
|
2539
2563
|
const retryAfter = suffix == null ? void 0 : suffix.match(RETRY_AFTER_SUFFIX);
|
|
@@ -2559,11 +2583,11 @@ function messageLength(message) {
|
|
|
2559
2583
|
if (typeof message === "string") {
|
|
2560
2584
|
return message.length;
|
|
2561
2585
|
}
|
|
2562
|
-
|
|
2586
|
+
_chunkHFE4VBQUcjs.assertUnreachable.call(void 0, message);
|
|
2563
2587
|
}
|
|
2564
2588
|
async function sendHttpRequest(opts) {
|
|
2565
2589
|
var _a, _b, _c;
|
|
2566
|
-
|
|
2590
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
2567
2591
|
msg: "sending http request",
|
|
2568
2592
|
url: opts.url,
|
|
2569
2593
|
encoding: opts.encoding
|
|
@@ -2572,8 +2596,8 @@ async function sendHttpRequest(opts) {
|
|
|
2572
2596
|
let bodyData;
|
|
2573
2597
|
if (opts.method === "POST" || opts.method === "PUT") {
|
|
2574
2598
|
_invariant2.default.call(void 0, opts.body !== void 0, "missing body");
|
|
2575
|
-
contentType =
|
|
2576
|
-
bodyData =
|
|
2599
|
+
contentType = _chunkHFE4VBQUcjs.contentTypeForEncoding.call(void 0, opts.encoding);
|
|
2600
|
+
bodyData = _chunkHFE4VBQUcjs.serializeWithEncoding.call(void 0,
|
|
2577
2601
|
opts.encoding,
|
|
2578
2602
|
opts.body,
|
|
2579
2603
|
opts.requestVersionedDataHandler,
|
|
@@ -2593,7 +2617,7 @@ async function sendHttpRequest(opts) {
|
|
|
2593
2617
|
...contentType ? {
|
|
2594
2618
|
"Content-Type": contentType
|
|
2595
2619
|
} : {},
|
|
2596
|
-
"User-Agent":
|
|
2620
|
+
"User-Agent": _chunkHFE4VBQUcjs.httpUserAgent.call(void 0, )
|
|
2597
2621
|
},
|
|
2598
2622
|
body: bodyData,
|
|
2599
2623
|
credentials: "include",
|
|
@@ -2614,7 +2638,7 @@ async function sendHttpRequest(opts) {
|
|
|
2614
2638
|
const rayId = response.headers.get("x-rivet-ray-id");
|
|
2615
2639
|
const encoding = (contentType2 == null ? void 0 : contentType2.includes("application/json")) ? "json" : opts.encoding;
|
|
2616
2640
|
try {
|
|
2617
|
-
const responseData =
|
|
2641
|
+
const responseData = _chunkHFE4VBQUcjs.deserializeWithEncoding.call(void 0,
|
|
2618
2642
|
encoding,
|
|
2619
2643
|
new Uint8Array(bufferResponse),
|
|
2620
2644
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
@@ -2632,7 +2656,7 @@ async function sendHttpRequest(opts) {
|
|
|
2632
2656
|
group: bare5.group,
|
|
2633
2657
|
code: bare5.code,
|
|
2634
2658
|
message: bare5.message,
|
|
2635
|
-
metadata: bare5.metadata ?
|
|
2659
|
+
metadata: bare5.metadata ? _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.metadata)) : void 0,
|
|
2636
2660
|
actor: bare5.actor ? {
|
|
2637
2661
|
actorId: bare5.actor.actorId,
|
|
2638
2662
|
generation: Number(bare5.actor.generation),
|
|
@@ -2640,7 +2664,7 @@ async function sendHttpRequest(opts) {
|
|
|
2640
2664
|
} : void 0
|
|
2641
2665
|
})
|
|
2642
2666
|
);
|
|
2643
|
-
|
|
2667
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
2644
2668
|
msg: "http error response",
|
|
2645
2669
|
group: responseData.group,
|
|
2646
2670
|
code: responseData.code,
|
|
@@ -2687,7 +2711,7 @@ ${textResponse}`
|
|
|
2687
2711
|
}
|
|
2688
2712
|
try {
|
|
2689
2713
|
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
2690
|
-
return
|
|
2714
|
+
return _chunkHFE4VBQUcjs.deserializeWithEncoding.call(void 0,
|
|
2691
2715
|
opts.encoding,
|
|
2692
2716
|
buffer,
|
|
2693
2717
|
opts.responseVersionedDataHandler,
|
|
@@ -2735,8 +2759,8 @@ function createQueueSender(senderOptions) {
|
|
|
2735
2759
|
}),
|
|
2736
2760
|
requestToBare: (value) => ({
|
|
2737
2761
|
name: _nullishCoalesce(value.name, () => ( name)),
|
|
2738
|
-
body:
|
|
2739
|
-
|
|
2762
|
+
body: _chunkHFE4VBQUcjs.bufferToArrayBuffer.call(void 0,
|
|
2763
|
+
_chunkHFE4VBQUcjs.encodeCborCompat.call(void 0, value.body)
|
|
2740
2764
|
),
|
|
2741
2765
|
wait: _nullishCoalesce(value.wait, () => ( false)),
|
|
2742
2766
|
timeout: value.timeout !== void 0 ? BigInt(value.timeout) : null
|
|
@@ -2756,7 +2780,7 @@ function createQueueSender(senderOptions) {
|
|
|
2756
2780
|
}
|
|
2757
2781
|
return {
|
|
2758
2782
|
status: bare5.status,
|
|
2759
|
-
response:
|
|
2783
|
+
response: _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.response))
|
|
2760
2784
|
};
|
|
2761
2785
|
}
|
|
2762
2786
|
});
|
|
@@ -2823,7 +2847,7 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}, t
|
|
|
2823
2847
|
throw new TypeError("Invalid input type for fetch");
|
|
2824
2848
|
}
|
|
2825
2849
|
try {
|
|
2826
|
-
|
|
2850
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug(
|
|
2827
2851
|
"directId" in target ? {
|
|
2828
2852
|
msg: "sending raw http request to actor",
|
|
2829
2853
|
actorId: target.directId
|
|
@@ -2858,7 +2882,7 @@ async function rawHttpFetch(driver, target, params, input, init, options = {}, t
|
|
|
2858
2882
|
actor,
|
|
2859
2883
|
public: isPublic,
|
|
2860
2884
|
statusCode
|
|
2861
|
-
} =
|
|
2885
|
+
} = _chunkHFE4VBQUcjs.deconstructError.call(void 0, err, true);
|
|
2862
2886
|
throw new (0, _chunkMGI2VVF6cjs.RivetError)(group, code, message, {
|
|
2863
2887
|
public: isPublic,
|
|
2864
2888
|
statusCode,
|
|
@@ -2885,7 +2909,7 @@ async function rawWebSocket(driver, target, params, path, _protocols, options =
|
|
|
2885
2909
|
}
|
|
2886
2910
|
}
|
|
2887
2911
|
const fullPath = `${PATH_WEBSOCKET_PREFIX}${pathPortion}${queryPortion}`;
|
|
2888
|
-
|
|
2912
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
2889
2913
|
msg: "opening websocket",
|
|
2890
2914
|
target,
|
|
2891
2915
|
encoding,
|
|
@@ -3034,7 +3058,7 @@ var ActorHandleRaw = class {
|
|
|
3034
3058
|
actor,
|
|
3035
3059
|
public: isPublic,
|
|
3036
3060
|
statusCode
|
|
3037
|
-
} =
|
|
3061
|
+
} = _chunkHFE4VBQUcjs.deconstructError.call(void 0, err, true);
|
|
3038
3062
|
if (this.#shouldRetryQueueDispatchOverload(
|
|
3039
3063
|
group,
|
|
3040
3064
|
code,
|
|
@@ -3163,13 +3187,13 @@ var ActorHandleRaw = class {
|
|
|
3163
3187
|
gatewayOptions
|
|
3164
3188
|
);
|
|
3165
3189
|
actorId = "directId" in target ? target.directId : void 0;
|
|
3166
|
-
|
|
3190
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug(
|
|
3167
3191
|
actorId ? { msg: "using direct actor gateway target", actorId } : {
|
|
3168
3192
|
msg: "using query gateway target for action",
|
|
3169
3193
|
query: this.#actorResolutionState
|
|
3170
3194
|
}
|
|
3171
3195
|
);
|
|
3172
|
-
|
|
3196
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3173
3197
|
msg: "handling action",
|
|
3174
3198
|
name: opts.name,
|
|
3175
3199
|
encoding: this.#encoding
|
|
@@ -3206,12 +3230,12 @@ var ActorHandleRaw = class {
|
|
|
3206
3230
|
args
|
|
3207
3231
|
}),
|
|
3208
3232
|
requestToBare: (args) => ({
|
|
3209
|
-
args:
|
|
3210
|
-
|
|
3233
|
+
args: _chunkHFE4VBQUcjs.bufferToArrayBuffer.call(void 0,
|
|
3234
|
+
_chunkHFE4VBQUcjs.encodeCborCompat.call(void 0, args)
|
|
3211
3235
|
)
|
|
3212
3236
|
}),
|
|
3213
3237
|
responseFromJson: (json) => json.output,
|
|
3214
|
-
responseFromBare: (bare5) =>
|
|
3238
|
+
responseFromBare: (bare5) => _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.output))
|
|
3215
3239
|
});
|
|
3216
3240
|
if (opts.name === "destroy" && actorId) {
|
|
3217
3241
|
await this.#waitForDestroyActionToSettle(actorId);
|
|
@@ -3227,7 +3251,7 @@ var ActorHandleRaw = class {
|
|
|
3227
3251
|
actor,
|
|
3228
3252
|
public: isPublic,
|
|
3229
3253
|
statusCode
|
|
3230
|
-
} =
|
|
3254
|
+
} = _chunkHFE4VBQUcjs.deconstructError.call(void 0, err, true);
|
|
3231
3255
|
if (await this.#shouldRetrySchedulingError(
|
|
3232
3256
|
group,
|
|
3233
3257
|
code,
|
|
@@ -3391,7 +3415,7 @@ var ActorHandleRaw = class {
|
|
|
3391
3415
|
* @returns {ActorConn<AD>} A connection to the actor.
|
|
3392
3416
|
*/
|
|
3393
3417
|
connect(params, options = {}) {
|
|
3394
|
-
|
|
3418
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3395
3419
|
msg: "establishing connection from handle",
|
|
3396
3420
|
query: this.#actorResolutionState
|
|
3397
3421
|
});
|
|
@@ -3477,7 +3501,7 @@ var ActorHandleRaw = class {
|
|
|
3477
3501
|
actor,
|
|
3478
3502
|
public: isPublic,
|
|
3479
3503
|
statusCode
|
|
3480
|
-
} =
|
|
3504
|
+
} = _chunkHFE4VBQUcjs.deconstructError.call(void 0, err, true);
|
|
3481
3505
|
if (await this.#shouldRetrySchedulingError(
|
|
3482
3506
|
group,
|
|
3483
3507
|
code,
|
|
@@ -3575,7 +3599,7 @@ var ActorHandleRaw = class {
|
|
|
3575
3599
|
const contentType = response.headers.get("content-type");
|
|
3576
3600
|
const encoding = (contentType == null ? void 0 : contentType.includes("application/json")) ? "json" : this.#encoding;
|
|
3577
3601
|
try {
|
|
3578
|
-
const error =
|
|
3602
|
+
const error = _chunkHFE4VBQUcjs.deserializeWithEncoding.call(void 0,
|
|
3579
3603
|
encoding,
|
|
3580
3604
|
new Uint8Array(await response.clone().arrayBuffer()),
|
|
3581
3605
|
HTTP_RESPONSE_ERROR_VERSIONED,
|
|
@@ -3591,7 +3615,7 @@ var ActorHandleRaw = class {
|
|
|
3591
3615
|
group: bare5.group,
|
|
3592
3616
|
code: bare5.code,
|
|
3593
3617
|
message: bare5.message,
|
|
3594
|
-
metadata: bare5.metadata ?
|
|
3618
|
+
metadata: bare5.metadata ? _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0, new Uint8Array(bare5.metadata)) : void 0,
|
|
3595
3619
|
actor: bare5.actor ? {
|
|
3596
3620
|
actorId: bare5.actor.actorId,
|
|
3597
3621
|
generation: Number(bare5.actor.generation),
|
|
@@ -3728,7 +3752,7 @@ var ClientRaw = (_class = class {
|
|
|
3728
3752
|
* @returns {ActorHandle<AD>} - A handle to the actor.
|
|
3729
3753
|
*/
|
|
3730
3754
|
getForId(name, actorId, opts) {
|
|
3731
|
-
|
|
3755
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3732
3756
|
msg: "get handle to actor with id",
|
|
3733
3757
|
name,
|
|
3734
3758
|
actorId,
|
|
@@ -3759,7 +3783,7 @@ var ClientRaw = (_class = class {
|
|
|
3759
3783
|
*/
|
|
3760
3784
|
get(name, key, opts) {
|
|
3761
3785
|
const keyArray = typeof key === "string" ? [key] : key || [];
|
|
3762
|
-
|
|
3786
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3763
3787
|
msg: "get handle to actor",
|
|
3764
3788
|
name,
|
|
3765
3789
|
key: keyArray,
|
|
@@ -3790,7 +3814,7 @@ var ClientRaw = (_class = class {
|
|
|
3790
3814
|
*/
|
|
3791
3815
|
getOrCreate(name, key, opts) {
|
|
3792
3816
|
const keyArray = typeof key === "string" ? [key] : key || [];
|
|
3793
|
-
|
|
3817
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3794
3818
|
msg: "get or create handle to actor",
|
|
3795
3819
|
name,
|
|
3796
3820
|
key: keyArray,
|
|
@@ -3834,7 +3858,7 @@ var ClientRaw = (_class = class {
|
|
|
3834
3858
|
key: keyArray
|
|
3835
3859
|
}
|
|
3836
3860
|
};
|
|
3837
|
-
|
|
3861
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3838
3862
|
msg: "create actor handle",
|
|
3839
3863
|
name,
|
|
3840
3864
|
key: keyArray,
|
|
@@ -3842,7 +3866,7 @@ var ClientRaw = (_class = class {
|
|
|
3842
3866
|
create: createQuery.create
|
|
3843
3867
|
});
|
|
3844
3868
|
const actorId = await resolveGatewayTarget(this.#driver, createQuery);
|
|
3845
|
-
|
|
3869
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3846
3870
|
msg: "created actor with ID",
|
|
3847
3871
|
name,
|
|
3848
3872
|
key: keyArray,
|
|
@@ -3863,6 +3887,49 @@ var ClientRaw = (_class = class {
|
|
|
3863
3887
|
const proxy = createActorProxy(handle);
|
|
3864
3888
|
return proxy;
|
|
3865
3889
|
}
|
|
3890
|
+
/**
|
|
3891
|
+
* Forks the actor `actorId` into a new actor and returns a handle to it.
|
|
3892
|
+
*
|
|
3893
|
+
* @template AD The actor class that this handle is for.
|
|
3894
|
+
* @param {string} name - The name of the actor; the source has the same name.
|
|
3895
|
+
* @param {string} actorId - The ID of the source actor.
|
|
3896
|
+
* @param {ForkOptions} [opts] - The new actor's key and the fork input.
|
|
3897
|
+
* @returns {Promise<ActorHandle<AD>>} - A promise that resolves to a handle to the new actor.
|
|
3898
|
+
*/
|
|
3899
|
+
async fork(name, actorId, opts) {
|
|
3900
|
+
const key = typeof (opts == null ? void 0 : opts.key) === "string" ? [opts.key] : opts == null ? void 0 : opts.key;
|
|
3901
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
3902
|
+
msg: "fork actor",
|
|
3903
|
+
name,
|
|
3904
|
+
sourceActorId: actorId,
|
|
3905
|
+
key
|
|
3906
|
+
});
|
|
3907
|
+
const forked = await retryOnLifecycleBoundary(
|
|
3908
|
+
() => this.#driver.forkActor({
|
|
3909
|
+
actorId,
|
|
3910
|
+
key,
|
|
3911
|
+
input: opts == null ? void 0 : opts.input
|
|
3912
|
+
}),
|
|
3913
|
+
{
|
|
3914
|
+
signal: opts == null ? void 0 : opts.signal,
|
|
3915
|
+
budget: this.#retryBudget,
|
|
3916
|
+
isRetryable: isRetryableForkRefusal
|
|
3917
|
+
}
|
|
3918
|
+
);
|
|
3919
|
+
const getForIdQuery = {
|
|
3920
|
+
getForId: {
|
|
3921
|
+
name,
|
|
3922
|
+
actorId: forked.actorId
|
|
3923
|
+
}
|
|
3924
|
+
};
|
|
3925
|
+
const handle = this.#createHandle(
|
|
3926
|
+
opts == null ? void 0 : opts.params,
|
|
3927
|
+
opts == null ? void 0 : opts.getParams,
|
|
3928
|
+
getForIdQuery,
|
|
3929
|
+
opts == null ? void 0 : opts.signal
|
|
3930
|
+
);
|
|
3931
|
+
return createActorProxy(handle);
|
|
3932
|
+
}
|
|
3866
3933
|
#createHandle(params, getParams, actorQuery, signal) {
|
|
3867
3934
|
return new ActorHandleRaw(
|
|
3868
3935
|
this,
|
|
@@ -3890,11 +3957,11 @@ var ClientRaw = (_class = class {
|
|
|
3890
3957
|
*/
|
|
3891
3958
|
async dispose() {
|
|
3892
3959
|
if (this.#disposed) {
|
|
3893
|
-
|
|
3960
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({ msg: "client already disconnected" });
|
|
3894
3961
|
return;
|
|
3895
3962
|
}
|
|
3896
3963
|
this.#disposed = true;
|
|
3897
|
-
|
|
3964
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({ msg: "disposing client" });
|
|
3898
3965
|
const disposePromises = [];
|
|
3899
3966
|
for (const conn of this[ACTOR_CONNS_SYMBOL].values()) {
|
|
3900
3967
|
disposePromises.push(conn.dispose());
|
|
@@ -3927,6 +3994,9 @@ function createClientWithDriver(driver, options = {}) {
|
|
|
3927
3994
|
},
|
|
3928
3995
|
create: async (key, opts = {}) => {
|
|
3929
3996
|
return await target.create(prop, key, opts);
|
|
3997
|
+
},
|
|
3998
|
+
fork: async (actorId, opts = {}) => {
|
|
3999
|
+
return await target.fork(prop, actorId, opts);
|
|
3930
4000
|
}
|
|
3931
4001
|
};
|
|
3932
4002
|
}
|
|
@@ -4087,6 +4157,7 @@ var ActorConnRaw = class {
|
|
|
4087
4157
|
#connStatus = "idle";
|
|
4088
4158
|
/** The opening failure that stopped retries. Later actions must fail instead of queueing. */
|
|
4089
4159
|
#connectionOpenError;
|
|
4160
|
+
#dispatchedErrors = /* @__PURE__ */ new WeakSet();
|
|
4090
4161
|
#actorId;
|
|
4091
4162
|
#connId;
|
|
4092
4163
|
#messageQueue = [];
|
|
@@ -4140,8 +4211,8 @@ var ActorConnRaw = class {
|
|
|
4140
4211
|
if ("getForId" in actorResolutionState) {
|
|
4141
4212
|
this.#actorId = actorResolutionState.getForId.actorId;
|
|
4142
4213
|
}
|
|
4143
|
-
this.#readyPromise =
|
|
4144
|
-
(reason) =>
|
|
4214
|
+
this.#readyPromise = _chunkHFE4VBQUcjs.promiseWithResolvers.call(void 0,
|
|
4215
|
+
(reason) => _chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
4145
4216
|
msg: "unhandled ready promise rejection",
|
|
4146
4217
|
reason
|
|
4147
4218
|
})
|
|
@@ -4184,7 +4255,13 @@ var ActorConnRaw = class {
|
|
|
4184
4255
|
return true;
|
|
4185
4256
|
}
|
|
4186
4257
|
#shouldReconnectForStaleActor(group, code) {
|
|
4187
|
-
|
|
4258
|
+
if (!isDynamicActorQuery(this.#actorResolutionState) || !isStaleResolvedActorError(group, code) || this.#onOpenPromise === void 0 || this.#connStatus === "connected") {
|
|
4259
|
+
return false;
|
|
4260
|
+
}
|
|
4261
|
+
if (isActorNotFound(group, code) && "getForKey" in this.#actorResolutionState) {
|
|
4262
|
+
return false;
|
|
4263
|
+
}
|
|
4264
|
+
return true;
|
|
4188
4265
|
}
|
|
4189
4266
|
send(name, body, options) {
|
|
4190
4267
|
return this.#sendQueueMessage(name, body, options);
|
|
@@ -4210,11 +4287,11 @@ var ActorConnRaw = class {
|
|
|
4210
4287
|
}
|
|
4211
4288
|
if (this.#disposed) throw new ActorConnDisposed();
|
|
4212
4289
|
if (this.#connectionOpenError) throw this.#connectionOpenError;
|
|
4213
|
-
|
|
4290
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({ msg: "action", name: opts.name, args: opts.args });
|
|
4214
4291
|
const actionId = this.#actionIdCounter;
|
|
4215
4292
|
this.#actionIdCounter += 1;
|
|
4216
|
-
const { promise, resolve, reject } =
|
|
4217
|
-
(reason) =>
|
|
4293
|
+
const { promise, resolve, reject } = _chunkHFE4VBQUcjs.promiseWithResolvers.call(void 0,
|
|
4294
|
+
(reason) => _chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
4218
4295
|
msg: "unhandled action promise rejection",
|
|
4219
4296
|
reason
|
|
4220
4297
|
})
|
|
@@ -4224,7 +4301,7 @@ var ActorConnRaw = class {
|
|
|
4224
4301
|
resolve,
|
|
4225
4302
|
reject
|
|
4226
4303
|
});
|
|
4227
|
-
|
|
4304
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4228
4305
|
msg: "added action to in-flight map",
|
|
4229
4306
|
actionId,
|
|
4230
4307
|
actionName: opts.name,
|
|
@@ -4264,9 +4341,9 @@ var ActorConnRaw = class {
|
|
|
4264
4341
|
try {
|
|
4265
4342
|
handler(status);
|
|
4266
4343
|
} catch (err) {
|
|
4267
|
-
|
|
4344
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4268
4345
|
msg: "error in status change handler",
|
|
4269
|
-
error:
|
|
4346
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4270
4347
|
});
|
|
4271
4348
|
}
|
|
4272
4349
|
}
|
|
@@ -4276,9 +4353,9 @@ var ActorConnRaw = class {
|
|
|
4276
4353
|
try {
|
|
4277
4354
|
handler();
|
|
4278
4355
|
} catch (err) {
|
|
4279
|
-
|
|
4356
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4280
4357
|
msg: "error in open handler",
|
|
4281
|
-
error:
|
|
4358
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4282
4359
|
});
|
|
4283
4360
|
}
|
|
4284
4361
|
}
|
|
@@ -4288,9 +4365,9 @@ var ActorConnRaw = class {
|
|
|
4288
4365
|
try {
|
|
4289
4366
|
handler();
|
|
4290
4367
|
} catch (err) {
|
|
4291
|
-
|
|
4368
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4292
4369
|
msg: "error in close handler",
|
|
4293
|
-
error:
|
|
4370
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4294
4371
|
});
|
|
4295
4372
|
}
|
|
4296
4373
|
}
|
|
@@ -4304,10 +4381,10 @@ var ActorConnRaw = class {
|
|
|
4304
4381
|
minTimeout: 250,
|
|
4305
4382
|
maxTimeout: 3e4,
|
|
4306
4383
|
onFailedAttempt: async (error) => {
|
|
4307
|
-
|
|
4384
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
4308
4385
|
msg: "failed to reconnect",
|
|
4309
4386
|
attempt: error.attemptNumber,
|
|
4310
|
-
error:
|
|
4387
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, error)
|
|
4311
4388
|
});
|
|
4312
4389
|
const hintMs = retryAfterMs(error);
|
|
4313
4390
|
if (hintMs !== void 0) {
|
|
@@ -4318,11 +4395,11 @@ var ActorConnRaw = class {
|
|
|
4318
4395
|
signal: this.#abortController.signal
|
|
4319
4396
|
}).catch((err) => {
|
|
4320
4397
|
if (err instanceof _pretry.AbortError || err.name === "AbortError" || !this.#shouldRetryConnectionOpenError(err)) {
|
|
4321
|
-
|
|
4398
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).info({ msg: "connection retry aborted" });
|
|
4322
4399
|
} else {
|
|
4323
|
-
|
|
4400
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4324
4401
|
msg: "unexpected error in connection retry",
|
|
4325
|
-
error:
|
|
4402
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4326
4403
|
});
|
|
4327
4404
|
}
|
|
4328
4405
|
});
|
|
@@ -4331,8 +4408,8 @@ var ActorConnRaw = class {
|
|
|
4331
4408
|
try {
|
|
4332
4409
|
if (this.#onOpenPromise)
|
|
4333
4410
|
throw new Error("#onOpenPromise already defined");
|
|
4334
|
-
this.#onOpenPromise =
|
|
4335
|
-
(reason) =>
|
|
4411
|
+
this.#onOpenPromise = _chunkHFE4VBQUcjs.promiseWithResolvers.call(void 0,
|
|
4412
|
+
(reason) => _chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
4336
4413
|
msg: "unhandled open promise rejection",
|
|
4337
4414
|
reason
|
|
4338
4415
|
})
|
|
@@ -4349,15 +4426,17 @@ var ActorConnRaw = class {
|
|
|
4349
4426
|
const actorError = error instanceof _chunkMGI2VVF6cjs.RivetError ? error : new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
4350
4427
|
"client",
|
|
4351
4428
|
"connection_open_failed",
|
|
4352
|
-
`Failed to open connection: ${
|
|
4353
|
-
{ error:
|
|
4429
|
+
`Failed to open connection: ${_chunkHFE4VBQUcjs.stringifyError.call(void 0, error)}`,
|
|
4430
|
+
{ error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, error) }
|
|
4354
4431
|
);
|
|
4355
4432
|
this.#connectionOpenError = actorError;
|
|
4356
4433
|
this.#rejectPendingPromises(actorError, false);
|
|
4357
|
-
this.#
|
|
4434
|
+
if (!this.#dispatchedErrors.has(actorError)) {
|
|
4435
|
+
this.#dispatchActorError(actorError);
|
|
4436
|
+
}
|
|
4358
4437
|
this.#setConnStatus("idle");
|
|
4359
4438
|
throw new (0, _pretry.AbortError)(
|
|
4360
|
-
error instanceof Error ? error : new Error(
|
|
4439
|
+
error instanceof Error ? error : new Error(_chunkHFE4VBQUcjs.stringifyError.call(void 0, error))
|
|
4361
4440
|
);
|
|
4362
4441
|
} finally {
|
|
4363
4442
|
this.#onOpenPromise = void 0;
|
|
@@ -4393,7 +4472,7 @@ var ActorConnRaw = class {
|
|
|
4393
4472
|
if (!ws) return;
|
|
4394
4473
|
this.#websocket = void 0;
|
|
4395
4474
|
this.#abandonedSockets.add(ws);
|
|
4396
|
-
|
|
4475
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4397
4476
|
msg: "closing failed connection attempt",
|
|
4398
4477
|
connId: this.#connId,
|
|
4399
4478
|
readyState: ws.readyState,
|
|
@@ -4402,9 +4481,9 @@ var ActorConnRaw = class {
|
|
|
4402
4481
|
try {
|
|
4403
4482
|
ws.close(1e3, reason);
|
|
4404
4483
|
} catch (err) {
|
|
4405
|
-
|
|
4484
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4406
4485
|
msg: "failed to close abandoned websocket",
|
|
4407
|
-
error:
|
|
4486
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4408
4487
|
});
|
|
4409
4488
|
}
|
|
4410
4489
|
}
|
|
@@ -4432,7 +4511,7 @@ var ActorConnRaw = class {
|
|
|
4432
4511
|
}
|
|
4433
4512
|
#clearQueuedMessages() {
|
|
4434
4513
|
if (this.#messageQueue.length === 0) return;
|
|
4435
|
-
|
|
4514
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4436
4515
|
msg: "clearing queued connection messages",
|
|
4437
4516
|
queueLength: this.#messageQueue.length
|
|
4438
4517
|
});
|
|
@@ -4445,7 +4524,7 @@ var ActorConnRaw = class {
|
|
|
4445
4524
|
try {
|
|
4446
4525
|
return await this.#getParams();
|
|
4447
4526
|
} catch (err) {
|
|
4448
|
-
const errorMessage =
|
|
4527
|
+
const errorMessage = _chunkHFE4VBQUcjs.stringifyError.call(void 0, err);
|
|
4449
4528
|
const error = new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
4450
4529
|
"client",
|
|
4451
4530
|
"get_params_failed",
|
|
@@ -4469,7 +4548,7 @@ var ActorConnRaw = class {
|
|
|
4469
4548
|
this.#gatewayOptions
|
|
4470
4549
|
);
|
|
4471
4550
|
_invariant2.default.call(void 0, ws, "websocket should have been created");
|
|
4472
|
-
|
|
4551
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4473
4552
|
msg: "opened websocket",
|
|
4474
4553
|
connId: this.#connId,
|
|
4475
4554
|
readyState: ws.readyState,
|
|
@@ -4479,7 +4558,7 @@ var ActorConnRaw = class {
|
|
|
4479
4558
|
ws.addEventListener("open", () => {
|
|
4480
4559
|
if (this.#websocket !== ws || this.#abandonedSockets.has(ws))
|
|
4481
4560
|
return;
|
|
4482
|
-
|
|
4561
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4483
4562
|
msg: "client websocket open",
|
|
4484
4563
|
connId: this.#connId
|
|
4485
4564
|
});
|
|
@@ -4490,9 +4569,9 @@ var ActorConnRaw = class {
|
|
|
4490
4569
|
try {
|
|
4491
4570
|
await this.#handleOnMessage(ev.data, ws);
|
|
4492
4571
|
} catch (err) {
|
|
4493
|
-
|
|
4572
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4494
4573
|
msg: "error in websocket message handler",
|
|
4495
|
-
error:
|
|
4574
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4496
4575
|
});
|
|
4497
4576
|
}
|
|
4498
4577
|
});
|
|
@@ -4502,9 +4581,9 @@ var ActorConnRaw = class {
|
|
|
4502
4581
|
try {
|
|
4503
4582
|
await this.#handleOnClose(ev);
|
|
4504
4583
|
} catch (err) {
|
|
4505
|
-
|
|
4584
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4506
4585
|
msg: "error in websocket close handler",
|
|
4507
|
-
error:
|
|
4586
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4508
4587
|
});
|
|
4509
4588
|
}
|
|
4510
4589
|
});
|
|
@@ -4514,9 +4593,9 @@ var ActorConnRaw = class {
|
|
|
4514
4593
|
try {
|
|
4515
4594
|
this.#handleOnError();
|
|
4516
4595
|
} catch (err) {
|
|
4517
|
-
|
|
4596
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4518
4597
|
msg: "error in websocket error handler",
|
|
4519
|
-
error:
|
|
4598
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4520
4599
|
});
|
|
4521
4600
|
}
|
|
4522
4601
|
});
|
|
@@ -4524,7 +4603,7 @@ var ActorConnRaw = class {
|
|
|
4524
4603
|
/** Called by the onopen event from drivers. */
|
|
4525
4604
|
#handleOnOpen() {
|
|
4526
4605
|
if (this.#disposed) {
|
|
4527
|
-
|
|
4606
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4528
4607
|
msg: "handleOnOpen called after dispose, closing websocket"
|
|
4529
4608
|
});
|
|
4530
4609
|
if (this.#websocket) {
|
|
@@ -4540,7 +4619,7 @@ var ActorConnRaw = class {
|
|
|
4540
4619
|
queueMicrotask(() => {
|
|
4541
4620
|
this.#openScheduled = false;
|
|
4542
4621
|
if (this.#disposed) {
|
|
4543
|
-
|
|
4622
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4544
4623
|
msg: "handleOnOpen scheduled after dispose, closing websocket"
|
|
4545
4624
|
});
|
|
4546
4625
|
if (this.#websocket) {
|
|
@@ -4549,7 +4628,7 @@ var ActorConnRaw = class {
|
|
|
4549
4628
|
}
|
|
4550
4629
|
return;
|
|
4551
4630
|
}
|
|
4552
|
-
|
|
4631
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4553
4632
|
msg: "socket open",
|
|
4554
4633
|
messageQueueLength: this.#messageQueue.length,
|
|
4555
4634
|
connId: this.#connId
|
|
@@ -4559,14 +4638,14 @@ var ActorConnRaw = class {
|
|
|
4559
4638
|
if (this.#onOpenPromise) {
|
|
4560
4639
|
this.#onOpenPromise.resolve(void 0);
|
|
4561
4640
|
} else {
|
|
4562
|
-
|
|
4641
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({ msg: "#onOpenPromise is undefined" });
|
|
4563
4642
|
}
|
|
4564
4643
|
for (const eventName of this.#eventSubscriptions.keys()) {
|
|
4565
4644
|
this.#sendSubscription(eventName, true);
|
|
4566
4645
|
}
|
|
4567
4646
|
const queue = this.#messageQueue;
|
|
4568
4647
|
this.#messageQueue = [];
|
|
4569
|
-
|
|
4648
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4570
4649
|
msg: "flushing message queue",
|
|
4571
4650
|
queueLength: queue.length
|
|
4572
4651
|
});
|
|
@@ -4578,7 +4657,7 @@ var ActorConnRaw = class {
|
|
|
4578
4657
|
/** Called by the onmessage event from drivers. */
|
|
4579
4658
|
async #handleOnMessage(data, socket) {
|
|
4580
4659
|
var _a;
|
|
4581
|
-
|
|
4660
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).trace({
|
|
4582
4661
|
msg: "received message",
|
|
4583
4662
|
dataType: typeof data,
|
|
4584
4663
|
isBlob: data instanceof Blob,
|
|
@@ -4587,16 +4666,16 @@ var ActorConnRaw = class {
|
|
|
4587
4666
|
const response = await this.#parseMessage(data);
|
|
4588
4667
|
if (this.#websocket !== socket || this.#abandonedSockets.has(socket))
|
|
4589
4668
|
return;
|
|
4590
|
-
|
|
4591
|
-
|
|
4669
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).trace(
|
|
4670
|
+
_chunkHFE4VBQUcjs.getLogMessage.call(void 0, ) ? {
|
|
4592
4671
|
msg: "parsed message",
|
|
4593
|
-
message:
|
|
4672
|
+
message: _chunkHFE4VBQUcjs.jsonStringifyCompat.call(void 0, response).substring(0, 100) + "..."
|
|
4594
4673
|
} : { msg: "parsed message" }
|
|
4595
4674
|
);
|
|
4596
4675
|
if (response.body.tag === "Init") {
|
|
4597
4676
|
this.#actorId = response.body.val.actorId;
|
|
4598
4677
|
this.#connId = response.body.val.connectionId;
|
|
4599
|
-
|
|
4678
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).trace({
|
|
4600
4679
|
msg: "received init message",
|
|
4601
4680
|
actorId: this.#actorId,
|
|
4602
4681
|
connId: this.#connId
|
|
@@ -4607,7 +4686,7 @@ var ActorConnRaw = class {
|
|
|
4607
4686
|
if (actionId !== null) {
|
|
4608
4687
|
const inFlight = this.#takeActionInFlight(Number(actionId));
|
|
4609
4688
|
this.#invalidateActorIfStale(group, code);
|
|
4610
|
-
|
|
4689
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
4611
4690
|
msg: "action error",
|
|
4612
4691
|
actionId,
|
|
4613
4692
|
actionName: inFlight == null ? void 0 : inFlight.name,
|
|
@@ -4626,7 +4705,7 @@ var ActorConnRaw = class {
|
|
|
4626
4705
|
})
|
|
4627
4706
|
);
|
|
4628
4707
|
} else {
|
|
4629
|
-
|
|
4708
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
4630
4709
|
msg: "connection error",
|
|
4631
4710
|
group,
|
|
4632
4711
|
code,
|
|
@@ -4671,27 +4750,27 @@ var ActorConnRaw = class {
|
|
|
4671
4750
|
}
|
|
4672
4751
|
} else if (response.body.tag === "ActionResponse") {
|
|
4673
4752
|
const { id: actionId } = response.body.val;
|
|
4674
|
-
|
|
4753
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4675
4754
|
msg: "received action response",
|
|
4676
4755
|
actionId: Number(actionId),
|
|
4677
4756
|
inFlightCount: this.#actionsInFlight.size,
|
|
4678
4757
|
inFlightIds: Array.from(this.#actionsInFlight.keys())
|
|
4679
4758
|
});
|
|
4680
4759
|
const inFlight = this.#takeActionInFlight(Number(actionId));
|
|
4681
|
-
|
|
4760
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).trace({
|
|
4682
4761
|
msg: "resolving action promise",
|
|
4683
4762
|
actionId,
|
|
4684
4763
|
actionName: inFlight == null ? void 0 : inFlight.name
|
|
4685
4764
|
});
|
|
4686
4765
|
inFlight.resolve(response.body.val);
|
|
4687
4766
|
} else if (response.body.tag === "Event") {
|
|
4688
|
-
|
|
4767
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).trace({
|
|
4689
4768
|
msg: "received event",
|
|
4690
4769
|
name: response.body.val.name
|
|
4691
4770
|
});
|
|
4692
4771
|
this.#dispatchEvent(response.body.val);
|
|
4693
4772
|
} else {
|
|
4694
|
-
|
|
4773
|
+
_chunkHFE4VBQUcjs.assertUnreachable.call(void 0, response.body);
|
|
4695
4774
|
}
|
|
4696
4775
|
}
|
|
4697
4776
|
/** Called by the onclose event from drivers. */
|
|
@@ -4701,7 +4780,7 @@ var ActorConnRaw = class {
|
|
|
4701
4780
|
const closeEvent = event;
|
|
4702
4781
|
const wasClean = closeEvent.wasClean;
|
|
4703
4782
|
const wasConnected = this.#connStatus === "connected";
|
|
4704
|
-
|
|
4783
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).info({
|
|
4705
4784
|
msg: "socket closed",
|
|
4706
4785
|
code: closeEvent.code,
|
|
4707
4786
|
reason: closeEvent.reason,
|
|
@@ -4729,7 +4808,7 @@ var ActorConnRaw = class {
|
|
|
4729
4808
|
this.#authRetryAvailable = false;
|
|
4730
4809
|
}
|
|
4731
4810
|
} catch (e4) {
|
|
4732
|
-
|
|
4811
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn("token renewal failed");
|
|
4733
4812
|
this.#authRetryAvailable = false;
|
|
4734
4813
|
}
|
|
4735
4814
|
} else if (isInvalidToken(group, code)) {
|
|
@@ -4787,8 +4866,18 @@ var ActorConnRaw = class {
|
|
|
4787
4866
|
if (error instanceof _chunkMGI2VVF6cjs.RivetError) {
|
|
4788
4867
|
this.#dispatchActorError(error);
|
|
4789
4868
|
}
|
|
4869
|
+
if (error instanceof _chunkMGI2VVF6cjs.RivetError && isActorDestroyed(error.group, error.code)) {
|
|
4870
|
+
this.#connectionOpenError = error;
|
|
4871
|
+
this.#setConnStatus("idle");
|
|
4872
|
+
return;
|
|
4873
|
+
}
|
|
4874
|
+
if (error instanceof _chunkMGI2VVF6cjs.RivetError && isInvalidToken(error.group, error.code) && !this.#authRetryAvailable) {
|
|
4875
|
+
this.#connectionOpenError = error;
|
|
4876
|
+
this.#setConnStatus("idle");
|
|
4877
|
+
return;
|
|
4878
|
+
}
|
|
4790
4879
|
if (wasConnected && this.#authRetryAvailable) {
|
|
4791
|
-
|
|
4880
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4792
4881
|
msg: "triggering reconnect",
|
|
4793
4882
|
connId: this.#connId
|
|
4794
4883
|
});
|
|
@@ -4813,12 +4902,12 @@ var ActorConnRaw = class {
|
|
|
4813
4902
|
/** Called by the onerror event from drivers. */
|
|
4814
4903
|
#handleOnError() {
|
|
4815
4904
|
if (this.#disposed) return;
|
|
4816
|
-
|
|
4905
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn("socket error");
|
|
4817
4906
|
}
|
|
4818
4907
|
#takeActionInFlight(id) {
|
|
4819
4908
|
const inFlight = this.#actionsInFlight.get(id);
|
|
4820
4909
|
if (!inFlight) {
|
|
4821
|
-
|
|
4910
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4822
4911
|
msg: "action not found in in-flight map",
|
|
4823
4912
|
lookupId: id,
|
|
4824
4913
|
inFlightCount: this.#actionsInFlight.size,
|
|
@@ -4833,7 +4922,7 @@ var ActorConnRaw = class {
|
|
|
4833
4922
|
throw internalClientError(`No in flight response for ${id}`);
|
|
4834
4923
|
}
|
|
4835
4924
|
this.#actionsInFlight.delete(id);
|
|
4836
|
-
|
|
4925
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
4837
4926
|
msg: "removed action from in-flight map",
|
|
4838
4927
|
actionId: id,
|
|
4839
4928
|
actionName: inFlight.name,
|
|
@@ -4856,13 +4945,14 @@ var ActorConnRaw = class {
|
|
|
4856
4945
|
}
|
|
4857
4946
|
}
|
|
4858
4947
|
#dispatchActorError(error) {
|
|
4948
|
+
this.#dispatchedErrors.add(error);
|
|
4859
4949
|
for (const handler of [...this.#errorHandlers]) {
|
|
4860
4950
|
try {
|
|
4861
4951
|
handler(error);
|
|
4862
4952
|
} catch (err) {
|
|
4863
|
-
|
|
4953
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4864
4954
|
msg: "error in connection error handler",
|
|
4865
|
-
error:
|
|
4955
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4866
4956
|
});
|
|
4867
4957
|
}
|
|
4868
4958
|
}
|
|
@@ -4967,9 +5057,9 @@ var ActorConnRaw = class {
|
|
|
4967
5057
|
try {
|
|
4968
5058
|
callback();
|
|
4969
5059
|
} catch (err) {
|
|
4970
|
-
|
|
5060
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).error({
|
|
4971
5061
|
msg: "error in open handler",
|
|
4972
|
-
error:
|
|
5062
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, err)
|
|
4973
5063
|
});
|
|
4974
5064
|
}
|
|
4975
5065
|
});
|
|
@@ -5019,7 +5109,7 @@ var ActorConnRaw = class {
|
|
|
5019
5109
|
let queueMessage = false;
|
|
5020
5110
|
if (this.#websocket) {
|
|
5021
5111
|
const readyState = this.#websocket.readyState;
|
|
5022
|
-
|
|
5112
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
5023
5113
|
msg: "websocket send attempt",
|
|
5024
5114
|
readyState,
|
|
5025
5115
|
readyStateString: readyState === 0 ? "CONNECTING" : readyState === 1 ? "OPEN" : readyState === 2 ? "CLOSING" : "CLOSED",
|
|
@@ -5028,7 +5118,7 @@ var ActorConnRaw = class {
|
|
|
5028
5118
|
actionName: (_a = message.body.val) == null ? void 0 : _a.name
|
|
5029
5119
|
});
|
|
5030
5120
|
if (this.#connStatus !== "connected") {
|
|
5031
|
-
|
|
5121
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
5032
5122
|
msg: "websocket init pending, queueing message",
|
|
5033
5123
|
connStatus: this.#connStatus,
|
|
5034
5124
|
messageType: message.body.tag
|
|
@@ -5036,7 +5126,7 @@ var ActorConnRaw = class {
|
|
|
5036
5126
|
queueMessage = true;
|
|
5037
5127
|
} else if (readyState === 1) {
|
|
5038
5128
|
try {
|
|
5039
|
-
const messageSerialized =
|
|
5129
|
+
const messageSerialized = _chunkHFE4VBQUcjs.serializeWithEncoding.call(void 0,
|
|
5040
5130
|
this.#encoding,
|
|
5041
5131
|
message,
|
|
5042
5132
|
CLIENT_PROTOCOL_TO_SERVER,
|
|
@@ -5053,8 +5143,8 @@ var ActorConnRaw = class {
|
|
|
5053
5143
|
val: {
|
|
5054
5144
|
id: msg.body.val.id,
|
|
5055
5145
|
name: msg.body.val.name,
|
|
5056
|
-
args:
|
|
5057
|
-
|
|
5146
|
+
args: _chunkHFE4VBQUcjs.bufferToArrayBuffer.call(void 0,
|
|
5147
|
+
_chunkHFE4VBQUcjs.encodeCborCompat.call(void 0,
|
|
5058
5148
|
msg.body.val.args
|
|
5059
5149
|
)
|
|
5060
5150
|
)
|
|
@@ -5068,12 +5158,12 @@ var ActorConnRaw = class {
|
|
|
5068
5158
|
);
|
|
5069
5159
|
this.#websocket.send(messageSerialized);
|
|
5070
5160
|
const serializedLength = messageLength(messageSerialized);
|
|
5071
|
-
|
|
5161
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).trace({
|
|
5072
5162
|
msg: "sent websocket message",
|
|
5073
5163
|
len: serializedLength
|
|
5074
5164
|
});
|
|
5075
5165
|
} catch (error) {
|
|
5076
|
-
|
|
5166
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
5077
5167
|
msg: "failed to send message, added to queue",
|
|
5078
5168
|
error,
|
|
5079
5169
|
connId: this.#connId
|
|
@@ -5081,19 +5171,19 @@ var ActorConnRaw = class {
|
|
|
5081
5171
|
queueMessage = true;
|
|
5082
5172
|
}
|
|
5083
5173
|
} else {
|
|
5084
|
-
|
|
5174
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
5085
5175
|
msg: "websocket not open, queueing message",
|
|
5086
5176
|
readyState
|
|
5087
5177
|
});
|
|
5088
5178
|
queueMessage = true;
|
|
5089
5179
|
}
|
|
5090
5180
|
} else {
|
|
5091
|
-
|
|
5181
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({ msg: "no websocket, queueing message" });
|
|
5092
5182
|
queueMessage = true;
|
|
5093
5183
|
}
|
|
5094
5184
|
if (!(opts == null ? void 0 : opts.ephemeral) && queueMessage) {
|
|
5095
5185
|
this.#messageQueue.push(message);
|
|
5096
|
-
|
|
5186
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({
|
|
5097
5187
|
msg: "queued connection message",
|
|
5098
5188
|
queueLength: this.#messageQueue.length,
|
|
5099
5189
|
connId: this.#connId,
|
|
@@ -5104,8 +5194,8 @@ var ActorConnRaw = class {
|
|
|
5104
5194
|
}
|
|
5105
5195
|
async #parseMessage(data) {
|
|
5106
5196
|
_invariant2.default.call(void 0, this.#websocket, "websocket must be defined");
|
|
5107
|
-
const buffer = await
|
|
5108
|
-
return
|
|
5197
|
+
const buffer = await _chunkHFE4VBQUcjs.inputDataToBuffer.call(void 0, data);
|
|
5198
|
+
return _chunkHFE4VBQUcjs.deserializeWithEncoding.call(void 0,
|
|
5109
5199
|
this.#encoding,
|
|
5110
5200
|
buffer,
|
|
5111
5201
|
CLIENT_PROTOCOL_TO_CLIENT,
|
|
@@ -5140,7 +5230,7 @@ var ActorConnRaw = class {
|
|
|
5140
5230
|
group: msg.body.val.group,
|
|
5141
5231
|
code: msg.body.val.code,
|
|
5142
5232
|
message: msg.body.val.message,
|
|
5143
|
-
metadata: msg.body.val.metadata ?
|
|
5233
|
+
metadata: msg.body.val.metadata ? _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0,
|
|
5144
5234
|
new Uint8Array(
|
|
5145
5235
|
msg.body.val.metadata
|
|
5146
5236
|
)
|
|
@@ -5162,7 +5252,7 @@ var ActorConnRaw = class {
|
|
|
5162
5252
|
tag: "ActionResponse",
|
|
5163
5253
|
val: {
|
|
5164
5254
|
id: msg.body.val.id,
|
|
5165
|
-
output:
|
|
5255
|
+
output: _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0,
|
|
5166
5256
|
new Uint8Array(msg.body.val.output)
|
|
5167
5257
|
)
|
|
5168
5258
|
}
|
|
@@ -5174,7 +5264,7 @@ var ActorConnRaw = class {
|
|
|
5174
5264
|
tag: "Event",
|
|
5175
5265
|
val: {
|
|
5176
5266
|
name: msg.body.val.name,
|
|
5177
|
-
args:
|
|
5267
|
+
args: _chunkHFE4VBQUcjs.decodeCborCompat.call(void 0,
|
|
5178
5268
|
new Uint8Array(msg.body.val.args)
|
|
5179
5269
|
)
|
|
5180
5270
|
}
|
|
@@ -5215,11 +5305,11 @@ var ActorConnRaw = class {
|
|
|
5215
5305
|
*/
|
|
5216
5306
|
async dispose() {
|
|
5217
5307
|
if (this.#disposed) {
|
|
5218
|
-
|
|
5308
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).warn({ msg: "connection already disconnected" });
|
|
5219
5309
|
return;
|
|
5220
5310
|
}
|
|
5221
5311
|
this.#disposed = true;
|
|
5222
|
-
|
|
5312
|
+
_chunkQM5MJLVCcjs.logger.call(void 0, ).debug({ msg: "disposing actor conn" });
|
|
5223
5313
|
this.#setConnStatus("idle");
|
|
5224
5314
|
clearInterval(this.#keepNodeAliveInterval);
|
|
5225
5315
|
this.#abortController.abort();
|
|
@@ -5227,8 +5317,8 @@ var ActorConnRaw = class {
|
|
|
5227
5317
|
if (this.#websocket) {
|
|
5228
5318
|
const ws = this.#websocket;
|
|
5229
5319
|
if (ws.readyState !== 2 && ws.readyState !== 3) {
|
|
5230
|
-
const { promise, resolve } =
|
|
5231
|
-
(reason) =>
|
|
5320
|
+
const { promise, resolve } = _chunkHFE4VBQUcjs.promiseWithResolvers.call(void 0,
|
|
5321
|
+
(reason) => _chunkQM5MJLVCcjs.logger.call(void 0, ).warn({
|
|
5232
5322
|
msg: "unhandled websocket close promise rejection",
|
|
5233
5323
|
reason
|
|
5234
5324
|
})
|
|
@@ -5366,7 +5456,7 @@ var ClientConfigSchemaBase = _v42.default.object({
|
|
|
5366
5456
|
* Defaults to http://localhost:6420.
|
|
5367
5457
|
*/
|
|
5368
5458
|
endpoint: _v42.default.string().optional().transform((val) => {
|
|
5369
|
-
const resolved = _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
5459
|
+
const resolved = _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkHFE4VBQUcjs.getRivetEngine.call(void 0, ))), () => ( _chunkHFE4VBQUcjs.getRivetEndpoint.call(void 0, )));
|
|
5370
5460
|
if (!resolved && !hasWarnedMissingEndpoint) {
|
|
5371
5461
|
hasWarnedMissingEndpoint = true;
|
|
5372
5462
|
console.warn(
|
|
@@ -5376,14 +5466,14 @@ var ClientConfigSchemaBase = _v42.default.object({
|
|
|
5376
5466
|
return _nullishCoalesce(resolved, () => ( DEFAULT_ENDPOINT));
|
|
5377
5467
|
}),
|
|
5378
5468
|
/** Token to use to authenticate with the API. */
|
|
5379
|
-
token: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
5469
|
+
token: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkHFE4VBQUcjs.getRivetToken.call(void 0, )))),
|
|
5380
5470
|
/** Issue and renew a client token on demand. Overrides the static token when provided. */
|
|
5381
5471
|
getToken: _v42.default.custom().optional(),
|
|
5382
5472
|
/** Namespace to connect to. */
|
|
5383
|
-
namespace: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
5473
|
+
namespace: _v42.default.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkHFE4VBQUcjs.getRivetNamespace.call(void 0, )))),
|
|
5384
5474
|
/** Name of the envoy pool. This is used to group together envoys in to different pools. */
|
|
5385
|
-
poolName: _v42.default.string().default(() => _nullishCoalesce(
|
|
5386
|
-
encoding:
|
|
5475
|
+
poolName: _v42.default.string().default(() => _nullishCoalesce(_chunkHFE4VBQUcjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
5476
|
+
encoding: _chunkHFE4VBQUcjs.EncodingSchema.default("bare"),
|
|
5387
5477
|
headers: _v42.default.record(_v42.default.string(), _v42.default.string()).optional().default(() => ({})),
|
|
5388
5478
|
gateway: _v42.default.object({
|
|
5389
5479
|
skipReadyWait: _v42.default.boolean().optional().default(false)
|
|
@@ -5518,6 +5608,9 @@ function buildGuardHeaders(runConfig, actorRequest, options) {
|
|
|
5518
5608
|
if (options.directActorId !== void 0) {
|
|
5519
5609
|
headers.set(HEADER_RIVET_TARGET, "actor");
|
|
5520
5610
|
headers.set(HEADER_RIVET_ACTOR, options.directActorId);
|
|
5611
|
+
if (runConfig.namespace) {
|
|
5612
|
+
headers.set(HEADER_RIVET_NAMESPACE, runConfig.namespace);
|
|
5613
|
+
}
|
|
5521
5614
|
}
|
|
5522
5615
|
if (shouldSkipReadyWait(options)) {
|
|
5523
5616
|
headers.set(HEADER_RIVET_SKIP_READY_WAIT, "1");
|
|
@@ -5568,7 +5661,7 @@ function setRemoteHibernatableWebSocketAckTestHooks(websocket, token, enabled) {
|
|
|
5568
5661
|
|
|
5569
5662
|
// src/engine-client/log.ts
|
|
5570
5663
|
function logger2() {
|
|
5571
|
-
return
|
|
5664
|
+
return _chunkHFE4VBQUcjs.getLogger.call(void 0, "engine-client");
|
|
5572
5665
|
}
|
|
5573
5666
|
|
|
5574
5667
|
// src/engine-client/actor-websocket-client.ts
|
|
@@ -5698,10 +5791,23 @@ var BufferedRemoteWebSocket = (_class2 = class {
|
|
|
5698
5791
|
return true;
|
|
5699
5792
|
}
|
|
5700
5793
|
}, _class2);
|
|
5701
|
-
function buildActorGatewayUrl(endpoint, actorId, token, path = "") {
|
|
5794
|
+
function buildActorGatewayUrl(endpoint, namespace, actorId, token, path = "") {
|
|
5795
|
+
if (namespace.length === 0) {
|
|
5796
|
+
throw new Error("actor gateway namespace must not be empty");
|
|
5797
|
+
}
|
|
5702
5798
|
const tokenSegment = token !== void 0 ? `@${encodeURIComponent(token)}` : "";
|
|
5703
|
-
const
|
|
5704
|
-
|
|
5799
|
+
const params = new URLSearchParams();
|
|
5800
|
+
params.append("rvt-namespace", namespace);
|
|
5801
|
+
let separator;
|
|
5802
|
+
if (path.endsWith("?") || path.endsWith("&")) {
|
|
5803
|
+
separator = "";
|
|
5804
|
+
} else if (path.includes("?")) {
|
|
5805
|
+
separator = "&";
|
|
5806
|
+
} else {
|
|
5807
|
+
separator = "?";
|
|
5808
|
+
}
|
|
5809
|
+
const gatewayPath = `/gateway/${encodeURIComponent(actorId)}${tokenSegment}${path}${separator}${params.toString()}`;
|
|
5810
|
+
return _chunkHFE4VBQUcjs.combineUrlPath.call(void 0, endpoint, gatewayPath);
|
|
5705
5811
|
}
|
|
5706
5812
|
function buildActorQueryGatewayUrl(endpoint, namespace, query, token, path = "", maxInputSize = DEFAULT_MAX_QUERY_INPUT_SIZE, crashPolicy = void 0, runnerName, options = {}) {
|
|
5707
5813
|
if (namespace.length === 0) {
|
|
@@ -5767,7 +5873,7 @@ function buildActorQueryGatewayUrl(endpoint, namespace, query, token, path = "",
|
|
|
5767
5873
|
separator = "?";
|
|
5768
5874
|
}
|
|
5769
5875
|
const gatewayPath = `/gateway/${encodeURIComponent(name)}${path}${separator}${queryString}`;
|
|
5770
|
-
return
|
|
5876
|
+
return _chunkHFE4VBQUcjs.combineUrlPath.call(void 0, endpoint, gatewayPath);
|
|
5771
5877
|
}
|
|
5772
5878
|
function pushKeyQueryParams(params, key) {
|
|
5773
5879
|
const rvtKey = _chunkRTWH3AX3cjs.actorKeyToGatewayQuery.call(void 0, key);
|
|
@@ -5779,7 +5885,7 @@ function pushInputQueryParam(params, input, maxInputSize) {
|
|
|
5779
5885
|
if (input === void 0) {
|
|
5780
5886
|
return;
|
|
5781
5887
|
}
|
|
5782
|
-
const encodedInput =
|
|
5888
|
+
const encodedInput = _chunkHFE4VBQUcjs.encodeCborCompat.call(void 0, input);
|
|
5783
5889
|
if (encodedInput.byteLength > maxInputSize) {
|
|
5784
5890
|
throw new Error(
|
|
5785
5891
|
`Actor query input exceeds maxInputSize (${encodedInput.byteLength} > ${maxInputSize} bytes). Increase client maxInputSize to allow larger query payloads.`
|
|
@@ -5788,10 +5894,10 @@ function pushInputQueryParam(params, input, maxInputSize) {
|
|
|
5788
5894
|
params.append("rvt-input", uint8ArrayToBase64Url(encodedInput));
|
|
5789
5895
|
}
|
|
5790
5896
|
function uint8ArrayToBase64Url(value) {
|
|
5791
|
-
return
|
|
5897
|
+
return _chunkHFE4VBQUcjs.uint8ArrayToBase64.call(void 0, value).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
|
|
5792
5898
|
}
|
|
5793
5899
|
async function openWebSocketToGateway(runConfig, gatewayUrl, encoding, params, options = {}) {
|
|
5794
|
-
const WebSocket2 = await
|
|
5900
|
+
const WebSocket2 = await _chunkQM5MJLVCcjs.importWebSocket.call(void 0, );
|
|
5795
5901
|
const ackHookToken = typeof process !== "undefined" && process.env.VITEST ? crypto.randomUUID() : void 0;
|
|
5796
5902
|
logger2().debug({
|
|
5797
5903
|
msg: "opening websocket to actor via guard",
|
|
@@ -5832,6 +5938,9 @@ function buildWebSocketProtocols(runConfig, encoding, params, ackHookToken, targ
|
|
|
5832
5938
|
if (target) {
|
|
5833
5939
|
protocols.push(`${WS_PROTOCOL_TARGET}${target.target}`);
|
|
5834
5940
|
protocols.push(`${WS_PROTOCOL_ACTOR}${target.actorId}`);
|
|
5941
|
+
if (runConfig.namespace) {
|
|
5942
|
+
protocols.push(`${WS_PROTOCOL_NAMESPACE}${runConfig.namespace}`);
|
|
5943
|
+
}
|
|
5835
5944
|
if (runConfig.token) {
|
|
5836
5945
|
protocols.push(`${WS_PROTOCOL_TOKEN}${runConfig.token}`);
|
|
5837
5946
|
}
|
|
@@ -5859,7 +5968,7 @@ function getEndpoint(config) {
|
|
|
5859
5968
|
}
|
|
5860
5969
|
async function apiCall(config, method, path, body) {
|
|
5861
5970
|
const endpoint = getEndpoint(config);
|
|
5862
|
-
const url =
|
|
5971
|
+
const url = _chunkHFE4VBQUcjs.combineUrlPath.call(void 0, endpoint, path, {
|
|
5863
5972
|
namespace: config.namespace
|
|
5864
5973
|
});
|
|
5865
5974
|
logger2().debug({ msg: "making api call", method, url });
|
|
@@ -5937,6 +6046,14 @@ async function createActor(config, request) {
|
|
|
5937
6046
|
request
|
|
5938
6047
|
);
|
|
5939
6048
|
}
|
|
6049
|
+
async function forkActor(config, actorId, request) {
|
|
6050
|
+
return apiCall(
|
|
6051
|
+
config,
|
|
6052
|
+
"POST",
|
|
6053
|
+
`/actors/${encodeURIComponent(actorId)}/fork`,
|
|
6054
|
+
request
|
|
6055
|
+
);
|
|
6056
|
+
}
|
|
5940
6057
|
async function destroyActor(config, actorId) {
|
|
5941
6058
|
return apiCall(
|
|
5942
6059
|
config,
|
|
@@ -5992,7 +6109,7 @@ async function lookupMetadataCached(config) {
|
|
|
5992
6109
|
msg: "failed to fetch metadata, retrying",
|
|
5993
6110
|
endpoint,
|
|
5994
6111
|
attempt: error.attemptNumber,
|
|
5995
|
-
error:
|
|
6112
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, error)
|
|
5996
6113
|
});
|
|
5997
6114
|
}
|
|
5998
6115
|
}
|
|
@@ -6004,7 +6121,7 @@ async function lookupMetadataCached(config) {
|
|
|
6004
6121
|
|
|
6005
6122
|
// src/engine-client/ws-proxy.ts
|
|
6006
6123
|
async function createWebSocketProxy(_c, targetUrl, protocols) {
|
|
6007
|
-
const WebSocket2 = await
|
|
6124
|
+
const WebSocket2 = await _chunkQM5MJLVCcjs.importWebSocket.call(void 0, );
|
|
6008
6125
|
const state = {};
|
|
6009
6126
|
return {
|
|
6010
6127
|
onOpen: async (_event, clientWs) => {
|
|
@@ -6069,7 +6186,7 @@ async function createWebSocketProxy(_c, targetUrl, protocols) {
|
|
|
6069
6186
|
logger2().error({
|
|
6070
6187
|
msg: "target websocket error",
|
|
6071
6188
|
targetUrl,
|
|
6072
|
-
error:
|
|
6189
|
+
error: _chunkHFE4VBQUcjs.stringifyError.call(void 0, error)
|
|
6073
6190
|
});
|
|
6074
6191
|
closeWebSocketIfOpen(clientWs, 1011, "Target WebSocket error");
|
|
6075
6192
|
});
|
|
@@ -6150,7 +6267,7 @@ var RemoteEngineControlClient = class {
|
|
|
6150
6267
|
#tokenProvider;
|
|
6151
6268
|
#webSocketTokens = /* @__PURE__ */ new WeakMap();
|
|
6152
6269
|
constructor(runConfig) {
|
|
6153
|
-
if (
|
|
6270
|
+
if (_chunkHFE4VBQUcjs.getNextPhase.call(void 0, ) === "phase-production-build") {
|
|
6154
6271
|
logger2().info(
|
|
6155
6272
|
"detected next.js build phase, disabling health check"
|
|
6156
6273
|
);
|
|
@@ -6289,8 +6406,8 @@ var RemoteEngineControlClient = class {
|
|
|
6289
6406
|
name,
|
|
6290
6407
|
key: _chunkRTWH3AX3cjs.serializeActorKey.call(void 0, key),
|
|
6291
6408
|
pool: _nullishCoalesce(poolName, () => ( this.#config.poolName)),
|
|
6292
|
-
input: actorInput ?
|
|
6293
|
-
|
|
6409
|
+
input: actorInput ? _chunkHFE4VBQUcjs.uint8ArrayToBase64.call(void 0,
|
|
6410
|
+
_chunkHFE4VBQUcjs.encodeCborCompat.call(void 0, actorInput)
|
|
6294
6411
|
) : void 0,
|
|
6295
6412
|
crash_policy: _nullishCoalesce(crashPolicy, () => ( "sleep"))
|
|
6296
6413
|
})
|
|
@@ -6343,8 +6460,8 @@ var RemoteEngineControlClient = class {
|
|
|
6343
6460
|
name,
|
|
6344
6461
|
pool: _nullishCoalesce(poolName, () => ( this.#config.poolName)),
|
|
6345
6462
|
key: _chunkRTWH3AX3cjs.serializeActorKey.call(void 0, key),
|
|
6346
|
-
input: input ?
|
|
6347
|
-
|
|
6463
|
+
input: input ? _chunkHFE4VBQUcjs.uint8ArrayToBase64.call(void 0,
|
|
6464
|
+
_chunkHFE4VBQUcjs.encodeCborCompat.call(void 0, input)
|
|
6348
6465
|
) : void 0,
|
|
6349
6466
|
crash_policy: _nullishCoalesce(crashPolicy, () => ( "sleep"))
|
|
6350
6467
|
})
|
|
@@ -6357,6 +6474,24 @@ var RemoteEngineControlClient = class {
|
|
|
6357
6474
|
});
|
|
6358
6475
|
return apiActorToOutput(result.actor);
|
|
6359
6476
|
}
|
|
6477
|
+
async forkActor({ actorId, key, input }) {
|
|
6478
|
+
await this.#metadataPromise;
|
|
6479
|
+
logger2().info({ msg: "forking actor via engine api", actorId, key });
|
|
6480
|
+
const result = await this.#withCredential(
|
|
6481
|
+
(config) => forkActor(config, actorId, {
|
|
6482
|
+
key: key ? _chunkRTWH3AX3cjs.serializeActorKey.call(void 0, key) : void 0,
|
|
6483
|
+
input: input !== void 0 ? _chunkHFE4VBQUcjs.uint8ArrayToBase64.call(void 0,
|
|
6484
|
+
_chunkHFE4VBQUcjs.encodeCborCompat.call(void 0, input)
|
|
6485
|
+
) : void 0
|
|
6486
|
+
})
|
|
6487
|
+
);
|
|
6488
|
+
logger2().info({
|
|
6489
|
+
msg: "actor forked",
|
|
6490
|
+
actorId: result.actor.actor_id,
|
|
6491
|
+
sourceActorId: actorId
|
|
6492
|
+
});
|
|
6493
|
+
return apiActorToOutput(result.actor);
|
|
6494
|
+
}
|
|
6360
6495
|
async listActors({ name }) {
|
|
6361
6496
|
await this.#metadataPromise;
|
|
6362
6497
|
logger2().debug({ msg: "listing actors via engine api", name });
|
|
@@ -6476,7 +6611,7 @@ var RemoteEngineControlClient = class {
|
|
|
6476
6611
|
const upgradeWebSocket = (_a = config.getUpgradeWebSocket) == null ? void 0 : _a.call(config);
|
|
6477
6612
|
_invariant2.default.call(void 0, upgradeWebSocket, "missing getUpgradeWebSocket");
|
|
6478
6613
|
const endpoint = getEndpoint(config);
|
|
6479
|
-
const guardUrl =
|
|
6614
|
+
const guardUrl = _chunkHFE4VBQUcjs.combineUrlPath.call(void 0, endpoint, path);
|
|
6480
6615
|
const wsGuardUrl = guardUrl.replace("http://", "ws://");
|
|
6481
6616
|
logger2().debug({
|
|
6482
6617
|
msg: "forwarding websocket to actor via guard",
|
|
@@ -6495,7 +6630,7 @@ var RemoteEngineControlClient = class {
|
|
|
6495
6630
|
}
|
|
6496
6631
|
);
|
|
6497
6632
|
const args = await createWebSocketProxy(c, wsGuardUrl, protocols);
|
|
6498
|
-
return await upgradeWebSocket(() => args)(c,
|
|
6633
|
+
return await upgradeWebSocket(() => args)(c, _chunkHFE4VBQUcjs.noopNext.call(void 0, ));
|
|
6499
6634
|
}
|
|
6500
6635
|
displayInformation() {
|
|
6501
6636
|
return { properties: {} };
|
|
@@ -6506,11 +6641,12 @@ var RemoteEngineControlClient = class {
|
|
|
6506
6641
|
#buildGatewayUrlForTarget(config, target, path, options = {}) {
|
|
6507
6642
|
const endpoint = getEndpoint(config);
|
|
6508
6643
|
if (shouldSkipReadyWait(options) && directActorIdFromTarget(target) && canUseDirectSkipReadyWaitPath(path)) {
|
|
6509
|
-
return
|
|
6644
|
+
return _chunkHFE4VBQUcjs.combineUrlPath.call(void 0, endpoint, path);
|
|
6510
6645
|
}
|
|
6511
6646
|
if ("directId" in target) {
|
|
6512
6647
|
return buildActorGatewayUrl(
|
|
6513
6648
|
endpoint,
|
|
6649
|
+
config.namespace,
|
|
6514
6650
|
target.directId,
|
|
6515
6651
|
config.token,
|
|
6516
6652
|
path
|
|
@@ -6519,6 +6655,7 @@ var RemoteEngineControlClient = class {
|
|
|
6519
6655
|
if ("getForId" in target) {
|
|
6520
6656
|
return buildActorGatewayUrl(
|
|
6521
6657
|
endpoint,
|
|
6658
|
+
config.namespace,
|
|
6522
6659
|
target.getForId.actorId,
|
|
6523
6660
|
config.token,
|
|
6524
6661
|
path
|
|
@@ -6607,4 +6744,4 @@ function apiActorToOutput(actor) {
|
|
|
6607
6744
|
|
|
6608
6745
|
|
|
6609
6746
|
exports.HEADER_CONN_PARAMS = HEADER_CONN_PARAMS; exports.HEADER_ORIGINAL_REQUEST_URL = HEADER_ORIGINAL_REQUEST_URL; exports.ALLOWED_PUBLIC_HEADERS = ALLOWED_PUBLIC_HEADERS; exports.ActorClientError = ActorClientError; exports.ManagerError = ManagerError; exports.MalformedResponseMessage = MalformedResponseMessage; exports.ActorConnDisposed = ActorConnDisposed; exports.readActiveTraceHeaders = readActiveTraceHeaders; exports.runWithActorInvocationSpan = runWithActorInvocationSpan; exports.ActorConnRaw = ActorConnRaw; exports.isResponseLike = isResponseLike; exports.ActorHandleRaw = ActorHandleRaw; exports.createClientWithDriver = createClientWithDriver; exports.ENGINE_HOST = ENGINE_HOST; exports.ENGINE_PORT = ENGINE_PORT; exports.buildEngineEndpoint = buildEngineEndpoint; exports.isLocalEngineEndpoint = isLocalEngineEndpoint; exports.tryParseEndpoint = tryParseEndpoint; exports.ClientConfigSchema = ClientConfigSchema; exports.convertRegistryConfigToClientConfig = convertRegistryConfigToClientConfig; exports.getDatacenters = getDatacenters; exports.updateRunnerConfig = updateRunnerConfig; exports.RemoteEngineControlClient = RemoteEngineControlClient;
|
|
6610
|
-
//# sourceMappingURL=chunk-
|
|
6747
|
+
//# sourceMappingURL=chunk-T5YMCOWY.cjs.map
|