rivetkit 0.0.0-sqlite-sync-3x-release.a00b07f → 0.0.0-sqlite-query-metrics-v2.f5d3605
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 +59 -99
- package/dist/browser/client.js +20 -193
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +2 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-D5WUPE47.js → chunk-3URZ4UV5.js} +2 -2
- package/dist/tsup/{chunk-TSQTI6H6.js → chunk-D4G35VTO.js} +4 -4
- package/dist/tsup/{chunk-OTVJYZ2L.cjs → chunk-DDS7OOVF.cjs} +166 -326
- package/dist/tsup/chunk-DDS7OOVF.cjs.map +1 -0
- package/dist/tsup/{chunk-6KXVLIXL.cjs → chunk-DHL2M2E2.cjs} +3 -3
- package/dist/tsup/{chunk-6KXVLIXL.cjs.map → chunk-DHL2M2E2.cjs.map} +1 -1
- package/dist/tsup/{chunk-ZYK4B5WV.js → chunk-E2CUROR3.js} +2 -2
- package/dist/tsup/{chunk-JUWMP5O3.js → chunk-EPRA2TCT.js} +2 -2
- package/dist/tsup/{chunk-3DONDAMG.js → chunk-F7IGTKGM.js} +2 -2
- package/dist/tsup/{chunk-BTSDFFDC.cjs → chunk-FYDB45YU.cjs} +10 -10
- package/dist/tsup/{chunk-BTSDFFDC.cjs.map → chunk-FYDB45YU.cjs.map} +1 -1
- package/dist/tsup/{chunk-73RNTXHB.cjs → chunk-HO76AEDH.cjs} +3 -3
- package/dist/tsup/{chunk-73RNTXHB.cjs.map → chunk-HO76AEDH.cjs.map} +1 -1
- package/dist/tsup/{chunk-A2CF6PFH.js → chunk-JI6GZ2C2.js} +1 -18
- package/dist/tsup/chunk-JI6GZ2C2.js.map +1 -0
- package/dist/tsup/{chunk-Z7E2G3JZ.cjs → chunk-JW2WPE6Z.cjs} +4 -4
- package/dist/tsup/{chunk-Z7E2G3JZ.cjs.map → chunk-JW2WPE6Z.cjs.map} +1 -1
- package/dist/tsup/{chunk-2MOLY6AM.cjs → chunk-KDT56V3Y.cjs} +11 -10
- package/dist/tsup/chunk-KDT56V3Y.cjs.map +1 -0
- package/dist/tsup/{chunk-DJUBJQEQ.js → chunk-KSP3NXGY.js} +3 -3
- package/dist/tsup/{chunk-JUHXV3HF.cjs → chunk-L3Z3W44Q.cjs} +3 -3
- package/dist/tsup/{chunk-JUHXV3HF.cjs.map → chunk-L3Z3W44Q.cjs.map} +1 -1
- package/dist/tsup/{chunk-RTWH3AX3.cjs → chunk-MYWZCDML.cjs} +2 -19
- package/dist/tsup/chunk-MYWZCDML.cjs.map +1 -0
- package/dist/tsup/{chunk-TRUHDXOU.js → chunk-PJ5EXY6F.js} +25 -185
- package/dist/tsup/chunk-PJ5EXY6F.js.map +1 -0
- package/dist/tsup/{chunk-TM76Z7XT.cjs → chunk-QR6EAWEC.cjs} +7 -7
- package/dist/tsup/{chunk-TM76Z7XT.cjs.map → chunk-QR6EAWEC.cjs.map} +1 -1
- package/dist/tsup/{chunk-BRH4PQS5.js → chunk-USKGKQZM.js} +11 -10
- package/dist/tsup/chunk-USKGKQZM.js.map +1 -0
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +3 -15
- package/dist/tsup/client/mod.d.ts +3 -15
- package/dist/tsup/client/mod.js +5 -5
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-DK144OAw.d.cts → config-CkmVg2fG.d.cts} +12 -58
- package/dist/tsup/{config-B4erdavw.d.ts → config-Cw_BwH_G.d.ts} +12 -58
- package/dist/tsup/{config-BfG1qpYz.d.cts → config-D4clT6mq.d.cts} +52 -34
- package/dist/tsup/{config-BfG1qpYz.d.ts → config-D4clT6mq.d.ts} +52 -34
- package/dist/tsup/{context-Oxi6YWcG.d.ts → context-BYOKTQJi.d.ts} +2 -2
- package/dist/tsup/{context-Cvnf3BRe.d.cts → context-_xIcgBnE.d.cts} +2 -2
- package/dist/tsup/db/drizzle.cjs +2 -2
- 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 +3 -3
- package/dist/tsup/db/mod.d.cts +2 -2
- package/dist/tsup/db/mod.d.ts +2 -2
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- 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.d.cts +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/mod.cjs +201 -548
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +4 -4
- package/dist/tsup/mod.d.ts +4 -4
- package/dist/tsup/mod.js +116 -463
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +7 -7
- package/dist/tsup/test/mod.d.cts +2 -2
- package/dist/tsup/test/mod.d.ts +2 -2
- package/dist/tsup/test/mod.js +5 -5
- package/dist/tsup/unstable/migrations.d.cts +1 -1
- package/dist/tsup/unstable/migrations.d.ts +1 -1
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +17 -17
- package/dist/tsup/workflow/mod.cjs.map +1 -1
- package/dist/tsup/workflow/mod.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +10 -9
- package/src/actor/config.test.ts +78 -0
- package/src/actor/keys.test.ts +275 -0
- package/src/actor/keys.ts +0 -86
- package/src/actor/utils.test.ts +48 -0
- package/src/client/actor-conn.ts +6 -92
- package/src/client/actor-handle.ts +3 -21
- package/src/client/client.ts +0 -6
- package/src/client/config.ts +1 -12
- package/src/client/lifecycle-errors.ts +1 -16
- package/src/client/test.ts +44 -0
- package/src/client/token-provider.test.ts +86 -0
- package/src/client/utils.ts +2 -13
- package/src/common/database/config.ts +52 -46
- package/src/common/database/mod.test.ts +364 -0
- package/src/common/database/native-database.test.ts +220 -0
- package/src/common/database/native-database.ts +27 -247
- package/src/common/inline-websocket-adapter.test.ts +51 -0
- package/src/common/router.ts +1 -1
- package/src/db/drizzle.test.ts +164 -0
- package/src/db/mod.ts +1 -0
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +2 -4
- package/src/engine-client/api-endpoints.ts +14 -44
- package/src/engine-client/mod.ts +2 -2
- package/src/registry/config/envoy.ts +1 -1
- package/src/registry/config/index.test.ts +25 -0
- package/src/registry/config/index.ts +31 -28
- package/src/registry/index.ts +19 -51
- package/src/registry/napi-runtime.ts +2 -81
- package/src/registry/native.ts +51 -183
- package/src/registry/run-handler-coordinator.test.ts +252 -0
- package/src/registry/runtime.test.ts +124 -0
- package/src/registry/runtime.ts +10 -79
- package/src/registry/wasm-runtime.ts +3 -94
- package/src/unstable/migrations.test.ts +170 -0
- package/src/utils/endpoint-parser.test.ts +206 -0
- package/src/utils/env-vars.ts +10 -15
- package/src/utils.test.ts +34 -0
- package/src/workflow/driver.test.ts +62 -0
- package/dist/tsup/chunk-2MOLY6AM.cjs.map +0 -1
- package/dist/tsup/chunk-A2CF6PFH.js.map +0 -1
- package/dist/tsup/chunk-BRH4PQS5.js.map +0 -1
- package/dist/tsup/chunk-OTVJYZ2L.cjs.map +0 -1
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +0 -1
- package/dist/tsup/chunk-TRUHDXOU.js.map +0 -1
- package/src/client/retry-budget.ts +0 -78
- /package/dist/tsup/{chunk-D5WUPE47.js.map → chunk-3URZ4UV5.js.map} +0 -0
- /package/dist/tsup/{chunk-TSQTI6H6.js.map → chunk-D4G35VTO.js.map} +0 -0
- /package/dist/tsup/{chunk-ZYK4B5WV.js.map → chunk-E2CUROR3.js.map} +0 -0
- /package/dist/tsup/{chunk-JUWMP5O3.js.map → chunk-EPRA2TCT.js.map} +0 -0
- /package/dist/tsup/{chunk-3DONDAMG.js.map → chunk-F7IGTKGM.js.map} +0 -0
- /package/dist/tsup/{chunk-DJUBJQEQ.js.map → chunk-KSP3NXGY.js.map} +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
actorKeyToGatewayQuery,
|
|
3
2
|
deserializeActorKey,
|
|
4
3
|
serializeActorKey
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JI6GZ2C2.js";
|
|
6
5
|
import {
|
|
7
6
|
importWebSocket,
|
|
8
7
|
logger
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-F7IGTKGM.js";
|
|
10
9
|
import {
|
|
11
10
|
AsyncMutex
|
|
12
11
|
} from "./chunk-JTHHCZCZ.js";
|
|
@@ -36,7 +35,7 @@ import {
|
|
|
36
35
|
serializeWithEncoding,
|
|
37
36
|
stringifyError,
|
|
38
37
|
uint8ArrayToBase64
|
|
39
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-USKGKQZM.js";
|
|
40
39
|
import {
|
|
41
40
|
INTERNAL_ERROR_CODE,
|
|
42
41
|
RivetError,
|
|
@@ -2177,56 +2176,6 @@ function readRequestBody(request) {
|
|
|
2177
2176
|
).arrayBuffer();
|
|
2178
2177
|
}
|
|
2179
2178
|
|
|
2180
|
-
// src/client/retry-budget.ts
|
|
2181
|
-
var DEFAULT_PERCENT = 10;
|
|
2182
|
-
var DEFAULT_MAX_TOKENS = 100;
|
|
2183
|
-
var RetryBudget = class {
|
|
2184
|
-
#tokens;
|
|
2185
|
-
#maxTokens;
|
|
2186
|
-
#deposit;
|
|
2187
|
-
constructor(options = {}) {
|
|
2188
|
-
const percent = options.percent ?? DEFAULT_PERCENT;
|
|
2189
|
-
const maxTokens = options.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
2190
|
-
if (!(percent >= 0 && percent <= 100)) {
|
|
2191
|
-
throw new Error("retryBudget.percent must be in 0..=100");
|
|
2192
|
-
}
|
|
2193
|
-
if (!(maxTokens >= 0)) {
|
|
2194
|
-
throw new Error("retryBudget.maxTokens must be at least 0");
|
|
2195
|
-
}
|
|
2196
|
-
this.#maxTokens = maxTokens;
|
|
2197
|
-
this.#tokens = maxTokens;
|
|
2198
|
-
this.#deposit = percent / 100;
|
|
2199
|
-
}
|
|
2200
|
-
/** Credits one request sent. */
|
|
2201
|
-
deposit() {
|
|
2202
|
-
this.#tokens = Math.min(this.#maxTokens, this.#tokens + this.#deposit);
|
|
2203
|
-
}
|
|
2204
|
-
/** Spends one token. Returns `false` when the budget is spent. */
|
|
2205
|
-
tryWithdraw() {
|
|
2206
|
-
if (this.#tokens + 1e-9 < 1) {
|
|
2207
|
-
return false;
|
|
2208
|
-
}
|
|
2209
|
-
this.#tokens = Math.max(0, this.#tokens - 1);
|
|
2210
|
-
return true;
|
|
2211
|
-
}
|
|
2212
|
-
};
|
|
2213
|
-
function retryAfterMs(error) {
|
|
2214
|
-
if (!(error instanceof RivetError)) {
|
|
2215
|
-
return void 0;
|
|
2216
|
-
}
|
|
2217
|
-
const metadata = error.metadata;
|
|
2218
|
-
if (metadata === null || typeof metadata !== "object") {
|
|
2219
|
-
return void 0;
|
|
2220
|
-
}
|
|
2221
|
-
const hint = metadata.retry_after_ms;
|
|
2222
|
-
return typeof hint === "number" && hint >= 0 ? hint : void 0;
|
|
2223
|
-
}
|
|
2224
|
-
function retryDelayMs(attempt, opts) {
|
|
2225
|
-
const backoff = Math.min(opts.initialDelayMs * 2 ** attempt, opts.maxDelayMs);
|
|
2226
|
-
const jittered = backoff / 2 + Math.random() * (backoff / 2);
|
|
2227
|
-
return Math.max(jittered, opts.hintMs ?? 0);
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
2179
|
// src/client/lifecycle-errors.ts
|
|
2231
2180
|
function* walkErrorChain(error, maxDepth = 8) {
|
|
2232
2181
|
let current = error;
|
|
@@ -2402,11 +2351,9 @@ async function waitWithSignal(ms, signal) {
|
|
|
2402
2351
|
});
|
|
2403
2352
|
}
|
|
2404
2353
|
async function retryOnLifecycleBoundary(run, opts) {
|
|
2405
|
-
var _a;
|
|
2406
2354
|
const maxAttempts = (opts == null ? void 0 : opts.maxAttempts) ?? 5;
|
|
2407
2355
|
const initialDelayMs = (opts == null ? void 0 : opts.initialDelayMs) ?? 25;
|
|
2408
2356
|
const maxDelayMs = (opts == null ? void 0 : opts.maxDelayMs) ?? 200;
|
|
2409
|
-
(_a = opts == null ? void 0 : opts.budget) == null ? void 0 : _a.deposit();
|
|
2410
2357
|
let lastError;
|
|
2411
2358
|
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
2412
2359
|
throwIfAborted(opts == null ? void 0 : opts.signal);
|
|
@@ -2420,14 +2367,7 @@ async function retryOnLifecycleBoundary(run, opts) {
|
|
|
2420
2367
|
if (attempt === maxAttempts - 1) {
|
|
2421
2368
|
break;
|
|
2422
2369
|
}
|
|
2423
|
-
|
|
2424
|
-
break;
|
|
2425
|
-
}
|
|
2426
|
-
const delayMs = retryDelayMs(attempt, {
|
|
2427
|
-
initialDelayMs,
|
|
2428
|
-
maxDelayMs,
|
|
2429
|
-
hintMs: retryAfterMs(error)
|
|
2430
|
-
});
|
|
2370
|
+
const delayMs = Math.min(initialDelayMs * 2 ** attempt, maxDelayMs);
|
|
2431
2371
|
await waitWithSignal(delayMs, opts == null ? void 0 : opts.signal);
|
|
2432
2372
|
}
|
|
2433
2373
|
}
|
|
@@ -2520,22 +2460,17 @@ function addOutboundTelemetryHeaders(headers, telemetry) {
|
|
|
2520
2460
|
|
|
2521
2461
|
// src/client/utils.ts
|
|
2522
2462
|
import invariant from "invariant";
|
|
2523
|
-
var RETRY_AFTER_SUFFIX = /^retry_after_ms=(\d+)$/;
|
|
2524
2463
|
function parseWebSocketCloseReason(reason) {
|
|
2525
|
-
const [mainPart,
|
|
2464
|
+
const [mainPart, rayId] = reason.split("#");
|
|
2526
2465
|
const [group, code] = mainPart.split(".");
|
|
2527
2466
|
if (!group || !code) {
|
|
2528
2467
|
logger().warn({ msg: "failed to parse close reason", reason });
|
|
2529
2468
|
return void 0;
|
|
2530
2469
|
}
|
|
2531
|
-
const retryAfter = suffix == null ? void 0 : suffix.match(RETRY_AFTER_SUFFIX);
|
|
2532
|
-
if (retryAfter) {
|
|
2533
|
-
return { group, code, retryAfterMs: Number(retryAfter[1]) };
|
|
2534
|
-
}
|
|
2535
2470
|
return {
|
|
2536
2471
|
group,
|
|
2537
2472
|
code,
|
|
2538
|
-
rayId
|
|
2473
|
+
rayId
|
|
2539
2474
|
};
|
|
2540
2475
|
}
|
|
2541
2476
|
function messageLength(message) {
|
|
@@ -2933,7 +2868,6 @@ var ActorHandleRaw = class {
|
|
|
2933
2868
|
#queueSendMutex = new AsyncMutex();
|
|
2934
2869
|
#currentActorInvocation;
|
|
2935
2870
|
#startCallSpan;
|
|
2936
|
-
#retryBudget;
|
|
2937
2871
|
/**
|
|
2938
2872
|
* Do not call this directly.
|
|
2939
2873
|
*
|
|
@@ -2941,7 +2875,7 @@ var ActorHandleRaw = class {
|
|
|
2941
2875
|
*
|
|
2942
2876
|
* @protected
|
|
2943
2877
|
*/
|
|
2944
|
-
constructor(client, driver, params, getParams, encoding, actorResolutionState, gatewayOptions = {}, signal, currentActorInvocation, startCallSpan
|
|
2878
|
+
constructor(client, driver, params, getParams, encoding, actorResolutionState, gatewayOptions = {}, signal, currentActorInvocation, startCallSpan) {
|
|
2945
2879
|
this.#client = client;
|
|
2946
2880
|
this.#driver = driver;
|
|
2947
2881
|
this.#encoding = encoding;
|
|
@@ -2952,7 +2886,6 @@ var ActorHandleRaw = class {
|
|
|
2952
2886
|
this.#signal = signal;
|
|
2953
2887
|
this.#currentActorInvocation = currentActorInvocation;
|
|
2954
2888
|
this.#startCallSpan = startCallSpan;
|
|
2955
|
-
this.#retryBudget = retryBudget;
|
|
2956
2889
|
}
|
|
2957
2890
|
async #resolveConnectionParams() {
|
|
2958
2891
|
if (this.#getParams) {
|
|
@@ -2969,7 +2902,6 @@ var ActorHandleRaw = class {
|
|
|
2969
2902
|
let useQueryTarget = isDynamicActorQuery(
|
|
2970
2903
|
this.#actorResolutionState
|
|
2971
2904
|
);
|
|
2972
|
-
this.#retryBudget.deposit();
|
|
2973
2905
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
2974
2906
|
let actorId;
|
|
2975
2907
|
try {
|
|
@@ -3006,17 +2938,8 @@ var ActorHandleRaw = class {
|
|
|
3006
2938
|
metadata,
|
|
3007
2939
|
attempt,
|
|
3008
2940
|
maxAttempts
|
|
3009
|
-
)
|
|
3010
|
-
await
|
|
3011
|
-
(resolve) => setTimeout(
|
|
3012
|
-
resolve,
|
|
3013
|
-
retryDelayMs(attempt, {
|
|
3014
|
-
initialDelayMs: 25,
|
|
3015
|
-
maxDelayMs: 1e3,
|
|
3016
|
-
hintMs: retryAfterMs(err)
|
|
3017
|
-
})
|
|
3018
|
-
)
|
|
3019
|
-
);
|
|
2941
|
+
)) {
|
|
2942
|
+
await this.#waitForRetryWindow();
|
|
3020
2943
|
continue;
|
|
3021
2944
|
}
|
|
3022
2945
|
if (await this.#shouldRetrySchedulingError(
|
|
@@ -3093,10 +3016,7 @@ var ActorHandleRaw = class {
|
|
|
3093
3016
|
if (opts.name === "destroy") {
|
|
3094
3017
|
return await run();
|
|
3095
3018
|
}
|
|
3096
|
-
return await retryOnLifecycleBoundary(run, {
|
|
3097
|
-
signal,
|
|
3098
|
-
budget: this.#retryBudget
|
|
3099
|
-
});
|
|
3019
|
+
return await retryOnLifecycleBoundary(run, { signal });
|
|
3100
3020
|
};
|
|
3101
3021
|
if (!call) {
|
|
3102
3022
|
return await send();
|
|
@@ -3638,7 +3558,6 @@ var ClientRaw = class {
|
|
|
3638
3558
|
#gatewayOptions;
|
|
3639
3559
|
#currentActorInvocation;
|
|
3640
3560
|
#startCallSpan;
|
|
3641
|
-
#retryBudget;
|
|
3642
3561
|
/**
|
|
3643
3562
|
* Creates an instance of Client.
|
|
3644
3563
|
*/
|
|
@@ -3651,7 +3570,6 @@ var ClientRaw = class {
|
|
|
3651
3570
|
this.#gatewayOptions = options.gateway ?? {};
|
|
3652
3571
|
this.#currentActorInvocation = options.currentActorInvocation;
|
|
3653
3572
|
this.#startCallSpan = options.startCallSpan;
|
|
3654
|
-
this.#retryBudget = new RetryBudget(options.retryBudget);
|
|
3655
3573
|
}
|
|
3656
3574
|
/**
|
|
3657
3575
|
* Gets a stateless handle to a actor by its ID.
|
|
@@ -3809,8 +3727,7 @@ var ClientRaw = class {
|
|
|
3809
3727
|
this.#gatewayOptions,
|
|
3810
3728
|
signal,
|
|
3811
3729
|
this.#currentActorInvocation,
|
|
3812
|
-
this.#startCallSpan
|
|
3813
|
-
this.#retryBudget
|
|
3730
|
+
this.#startCallSpan
|
|
3814
3731
|
);
|
|
3815
3732
|
}
|
|
3816
3733
|
[CREATE_ACTOR_CONN_PROXY](conn) {
|
|
@@ -4010,10 +3927,6 @@ function jwtExpiration(token) {
|
|
|
4010
3927
|
}
|
|
4011
3928
|
|
|
4012
3929
|
// src/client/actor-conn.ts
|
|
4013
|
-
var CONNECT_TIMEOUT_MS = 2e4;
|
|
4014
|
-
function isConnectionOpenTimeout(error) {
|
|
4015
|
-
return error instanceof RivetError && error.group === "client" && error.code === "connection_open_timeout";
|
|
4016
|
-
}
|
|
4017
3930
|
var CONNECT_SYMBOL = /* @__PURE__ */ Symbol("connect");
|
|
4018
3931
|
var ActorConnRaw = class {
|
|
4019
3932
|
#disposed = false;
|
|
@@ -4041,8 +3954,6 @@ var ActorConnRaw = class {
|
|
|
4041
3954
|
#keepNodeAliveInterval;
|
|
4042
3955
|
/** Promise used to indicate the socket has connected successfully. This will be rejected if the connection fails. */
|
|
4043
3956
|
#onOpenPromise;
|
|
4044
|
-
/** Sockets given up on by the connect timeout. Their late events are ignored. */
|
|
4045
|
-
#abandonedSockets = /* @__PURE__ */ new WeakSet();
|
|
4046
3957
|
#websocket;
|
|
4047
3958
|
#authRetryAvailable = true;
|
|
4048
3959
|
#client;
|
|
@@ -4233,16 +4144,12 @@ var ActorConnRaw = class {
|
|
|
4233
4144
|
forever: true,
|
|
4234
4145
|
minTimeout: 250,
|
|
4235
4146
|
maxTimeout: 3e4,
|
|
4236
|
-
onFailedAttempt:
|
|
4147
|
+
onFailedAttempt: (error) => {
|
|
4237
4148
|
logger().warn({
|
|
4238
4149
|
msg: "failed to reconnect",
|
|
4239
4150
|
attempt: error.attemptNumber,
|
|
4240
4151
|
error: stringifyError(error)
|
|
4241
4152
|
});
|
|
4242
|
-
const hintMs = retryAfterMs(error);
|
|
4243
|
-
if (hintMs !== void 0) {
|
|
4244
|
-
await new Promise((resolve) => setTimeout(resolve, hintMs));
|
|
4245
|
-
}
|
|
4246
4153
|
},
|
|
4247
4154
|
// Cancel retry if aborted
|
|
4248
4155
|
signal: this.#abortController.signal
|
|
@@ -4268,7 +4175,7 @@ var ActorConnRaw = class {
|
|
|
4268
4175
|
})
|
|
4269
4176
|
);
|
|
4270
4177
|
await this.#connectWebSocket();
|
|
4271
|
-
await this.#
|
|
4178
|
+
await this.#onOpenPromise.promise;
|
|
4272
4179
|
} catch (error) {
|
|
4273
4180
|
if (this.#shouldRetryConnectionOpenError(error)) {
|
|
4274
4181
|
throw error;
|
|
@@ -4290,63 +4197,10 @@ var ActorConnRaw = class {
|
|
|
4290
4197
|
this.#onOpenPromise = void 0;
|
|
4291
4198
|
}
|
|
4292
4199
|
}
|
|
4293
|
-
/**
|
|
4294
|
-
* Waits for the actor's Init on the current socket, up to {@link CONNECT_TIMEOUT_MS}. A socket
|
|
4295
|
-
* can stay connecting with no open, error or close event, as when the engine holds the
|
|
4296
|
-
* upgrade or a refused connect reports only an error. On timeout the socket is abandoned
|
|
4297
|
-
* and closed, and the retryable `client.connection_open_timeout` starts the next attempt.
|
|
4298
|
-
*/
|
|
4299
|
-
async #waitForOpen(open) {
|
|
4300
|
-
let timer;
|
|
4301
|
-
const timedOut = new Promise((_, reject) => {
|
|
4302
|
-
timer = setTimeout(() => {
|
|
4303
|
-
reject(
|
|
4304
|
-
new RivetError(
|
|
4305
|
-
"client",
|
|
4306
|
-
"connection_open_timeout",
|
|
4307
|
-
`Connection did not open within ${CONNECT_TIMEOUT_MS} ms`
|
|
4308
|
-
)
|
|
4309
|
-
);
|
|
4310
|
-
}, CONNECT_TIMEOUT_MS);
|
|
4311
|
-
});
|
|
4312
|
-
try {
|
|
4313
|
-
await Promise.race([open, timedOut]);
|
|
4314
|
-
} catch (error) {
|
|
4315
|
-
if (isConnectionOpenTimeout(error)) {
|
|
4316
|
-
this.#abandonCurrentSocket();
|
|
4317
|
-
}
|
|
4318
|
-
throw error;
|
|
4319
|
-
} finally {
|
|
4320
|
-
clearTimeout(timer);
|
|
4321
|
-
}
|
|
4322
|
-
}
|
|
4323
|
-
#abandonCurrentSocket() {
|
|
4324
|
-
const ws = this.#websocket;
|
|
4325
|
-
if (!ws) return;
|
|
4326
|
-
this.#websocket = void 0;
|
|
4327
|
-
this.#abandonedSockets.add(ws);
|
|
4328
|
-
logger().warn({
|
|
4329
|
-
msg: "connection did not open in time, retrying",
|
|
4330
|
-
connId: this.#connId,
|
|
4331
|
-
readyState: ws.readyState,
|
|
4332
|
-
timeoutMs: CONNECT_TIMEOUT_MS
|
|
4333
|
-
});
|
|
4334
|
-
try {
|
|
4335
|
-
ws.close(1e3, "Connect timeout");
|
|
4336
|
-
} catch (err) {
|
|
4337
|
-
logger().debug({
|
|
4338
|
-
msg: "failed to close abandoned websocket",
|
|
4339
|
-
error: stringifyError(err)
|
|
4340
|
-
});
|
|
4341
|
-
}
|
|
4342
|
-
}
|
|
4343
4200
|
#shouldRetryConnectionOpenError(error) {
|
|
4344
4201
|
if (error instanceof ActorConnDisposed) {
|
|
4345
4202
|
return false;
|
|
4346
4203
|
}
|
|
4347
|
-
if (isConnectionOpenTimeout(error)) {
|
|
4348
|
-
return true;
|
|
4349
|
-
}
|
|
4350
4204
|
if (error instanceof RivetError && isInvalidToken(error.group, error.code) && this.#driver.refreshAuthToken && this.#authRetryAvailable) {
|
|
4351
4205
|
this.#authRetryAvailable = false;
|
|
4352
4206
|
return true;
|
|
@@ -4406,14 +4260,12 @@ var ActorConnRaw = class {
|
|
|
4406
4260
|
});
|
|
4407
4261
|
this.#websocket = ws;
|
|
4408
4262
|
ws.addEventListener("open", () => {
|
|
4409
|
-
if (this.#abandonedSockets.has(ws)) return;
|
|
4410
4263
|
logger().debug({
|
|
4411
4264
|
msg: "client websocket open",
|
|
4412
4265
|
connId: this.#connId
|
|
4413
4266
|
});
|
|
4414
4267
|
});
|
|
4415
4268
|
ws.addEventListener("message", async (ev) => {
|
|
4416
|
-
if (this.#abandonedSockets.has(ws)) return;
|
|
4417
4269
|
try {
|
|
4418
4270
|
await this.#handleOnMessage(ev.data);
|
|
4419
4271
|
} catch (err) {
|
|
@@ -4424,7 +4276,6 @@ var ActorConnRaw = class {
|
|
|
4424
4276
|
}
|
|
4425
4277
|
});
|
|
4426
4278
|
ws.addEventListener("close", async (ev) => {
|
|
4427
|
-
if (this.#abandonedSockets.has(ws)) return;
|
|
4428
4279
|
try {
|
|
4429
4280
|
await this.#handleOnClose(ev);
|
|
4430
4281
|
} catch (err) {
|
|
@@ -4435,7 +4286,6 @@ var ActorConnRaw = class {
|
|
|
4435
4286
|
}
|
|
4436
4287
|
});
|
|
4437
4288
|
ws.addEventListener("error", () => {
|
|
4438
|
-
if (this.#abandonedSockets.has(ws)) return;
|
|
4439
4289
|
try {
|
|
4440
4290
|
this.#handleOnError();
|
|
4441
4291
|
} catch (err) {
|
|
@@ -4644,8 +4494,7 @@ var ActorConnRaw = class {
|
|
|
4644
4494
|
const reason = closeEvent.reason || "";
|
|
4645
4495
|
const parsed = parseWebSocketCloseReason(reason);
|
|
4646
4496
|
if (parsed) {
|
|
4647
|
-
const { group, code, rayId
|
|
4648
|
-
const closeOptions = retryAfterMs2 === void 0 ? { rayId } : { rayId, metadata: { retry_after_ms: retryAfterMs2 } };
|
|
4497
|
+
const { group, code, rayId } = parsed;
|
|
4649
4498
|
if (isInvalidToken(group, code) && closeEvent.code === 1008 && failedSocket) {
|
|
4650
4499
|
try {
|
|
4651
4500
|
if (!await ((_b = (_a = this.#driver).refreshAuthToken) == null ? void 0 : _b.call(
|
|
@@ -4668,7 +4517,7 @@ var ActorConnRaw = class {
|
|
|
4668
4517
|
group,
|
|
4669
4518
|
code,
|
|
4670
4519
|
`Connection closed: ${reason}`,
|
|
4671
|
-
|
|
4520
|
+
{ rayId }
|
|
4672
4521
|
)
|
|
4673
4522
|
);
|
|
4674
4523
|
return;
|
|
@@ -4689,7 +4538,7 @@ var ActorConnRaw = class {
|
|
|
4689
4538
|
group,
|
|
4690
4539
|
code,
|
|
4691
4540
|
`Connection closed: ${reason}`,
|
|
4692
|
-
|
|
4541
|
+
{ rayId }
|
|
4693
4542
|
);
|
|
4694
4543
|
}
|
|
4695
4544
|
} else {
|
|
@@ -4697,7 +4546,7 @@ var ActorConnRaw = class {
|
|
|
4697
4546
|
group,
|
|
4698
4547
|
code,
|
|
4699
4548
|
`Connection closed: ${reason}`,
|
|
4700
|
-
|
|
4549
|
+
{ rayId }
|
|
4701
4550
|
);
|
|
4702
4551
|
}
|
|
4703
4552
|
this.#invalidateActorIfStale(group, code);
|
|
@@ -5315,14 +5164,6 @@ var ClientConfigSchemaBase = z2.object({
|
|
|
5315
5164
|
// This is required in the client config in order to support
|
|
5316
5165
|
// `proxyWebSocket`
|
|
5317
5166
|
getUpgradeWebSocket: z2.custom().optional(),
|
|
5318
|
-
/**
|
|
5319
|
-
* Bounds retries of refused requests: `percent` retries per 100 requests (default 10), with
|
|
5320
|
-
* up to `maxTokens` banked for bursts (default 100). A refusal past the budget is thrown.
|
|
5321
|
-
*/
|
|
5322
|
-
retryBudget: z2.object({
|
|
5323
|
-
percent: z2.number().min(0).max(100).optional(),
|
|
5324
|
-
maxTokens: z2.number().int().min(0).optional()
|
|
5325
|
-
}).optional(),
|
|
5326
5167
|
/** Replaces global fetch for actor HTTP gateway requests. */
|
|
5327
5168
|
fetch: z2.custom().optional(),
|
|
5328
5169
|
/** Whether to automatically perform health checks when the client is created. */
|
|
@@ -5365,7 +5206,7 @@ function convertRegistryConfigToClientConfig(config) {
|
|
|
5365
5206
|
token: config.token,
|
|
5366
5207
|
getToken: void 0,
|
|
5367
5208
|
namespace: config.namespace,
|
|
5368
|
-
poolName: config.
|
|
5209
|
+
poolName: config.envoy.poolName,
|
|
5369
5210
|
headers: config.headers,
|
|
5370
5211
|
gateway: { skipReadyWait: false },
|
|
5371
5212
|
encoding: "bare",
|
|
@@ -5692,9 +5533,8 @@ function buildActorQueryGatewayUrl(endpoint, namespace, query, token, path = "",
|
|
|
5692
5533
|
return combineUrlPath(endpoint, gatewayPath);
|
|
5693
5534
|
}
|
|
5694
5535
|
function pushKeyQueryParams(params, key) {
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
params.append("rvt-key", rvtKey);
|
|
5536
|
+
if (key.length > 0) {
|
|
5537
|
+
params.append("rvt-key", key.join(","));
|
|
5698
5538
|
}
|
|
5699
5539
|
}
|
|
5700
5540
|
function pushInputQueryParam(params, input, maxInputSize) {
|
|
@@ -5876,8 +5716,8 @@ async function updateRunnerConfig(config, runnerName, request) {
|
|
|
5876
5716
|
return apiCall(
|
|
5877
5717
|
config,
|
|
5878
5718
|
"PUT",
|
|
5879
|
-
`/
|
|
5880
|
-
|
|
5719
|
+
`/runner-configs/${runnerName}`,
|
|
5720
|
+
request
|
|
5881
5721
|
);
|
|
5882
5722
|
}
|
|
5883
5723
|
|
|
@@ -6210,7 +6050,7 @@ var RemoteEngineControlClient = class {
|
|
|
6210
6050
|
datacenter: region,
|
|
6211
6051
|
name,
|
|
6212
6052
|
key: serializeActorKey(key),
|
|
6213
|
-
|
|
6053
|
+
runner_name_selector: poolName ?? this.#config.poolName,
|
|
6214
6054
|
input: actorInput ? uint8ArrayToBase64(
|
|
6215
6055
|
encodeCborCompat(actorInput)
|
|
6216
6056
|
) : void 0,
|
|
@@ -6263,7 +6103,7 @@ var RemoteEngineControlClient = class {
|
|
|
6263
6103
|
(config) => createActor(config, {
|
|
6264
6104
|
datacenter: region,
|
|
6265
6105
|
name,
|
|
6266
|
-
|
|
6106
|
+
runner_name_selector: poolName ?? this.#config.poolName,
|
|
6267
6107
|
key: serializeActorKey(key),
|
|
6268
6108
|
input: input ? uint8ArrayToBase64(
|
|
6269
6109
|
encodeCborCompat(input)
|
|
@@ -6529,4 +6369,4 @@ export {
|
|
|
6529
6369
|
updateRunnerConfig,
|
|
6530
6370
|
RemoteEngineControlClient
|
|
6531
6371
|
};
|
|
6532
|
-
//# sourceMappingURL=chunk-
|
|
6372
|
+
//# sourceMappingURL=chunk-PJ5EXY6F.js.map
|