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
package/dist/tsup/mod.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeWorkflowHistoryTransport
|
|
3
|
+
} from "./chunk-3URZ4UV5.js";
|
|
1
4
|
import {
|
|
2
5
|
ACTOR_CONTEXT_INTERNAL_SYMBOL,
|
|
3
6
|
ActorConfigSchema,
|
|
@@ -15,9 +18,6 @@ import {
|
|
|
15
18
|
getRunMetadata,
|
|
16
19
|
hasRunInspectorConfig
|
|
17
20
|
} from "./chunk-6FEYCVZC.js";
|
|
18
|
-
import {
|
|
19
|
-
decodeWorkflowHistoryTransport
|
|
20
|
-
} from "./chunk-D5WUPE47.js";
|
|
21
21
|
import {
|
|
22
22
|
ALLOWED_PUBLIC_HEADERS,
|
|
23
23
|
ENGINE_HOST,
|
|
@@ -35,17 +35,17 @@ import {
|
|
|
35
35
|
runWithActorInvocationSpan,
|
|
36
36
|
tryParseEndpoint,
|
|
37
37
|
updateRunnerConfig
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-PJ5EXY6F.js";
|
|
39
39
|
import {
|
|
40
40
|
makePrefixedKey,
|
|
41
41
|
removePrefixFromKey
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import "./chunk-
|
|
42
|
+
} from "./chunk-JI6GZ2C2.js";
|
|
43
|
+
import "./chunk-F7IGTKGM.js";
|
|
44
44
|
import {
|
|
45
45
|
bindNativeStateTransactionContext,
|
|
46
46
|
db,
|
|
47
47
|
registerNativeStateTransactionOpener
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-E2CUROR3.js";
|
|
49
49
|
import "./chunk-JTHHCZCZ.js";
|
|
50
50
|
import {
|
|
51
51
|
LogLevelSchema,
|
|
@@ -80,12 +80,11 @@ import {
|
|
|
80
80
|
parsePortEnv,
|
|
81
81
|
stringifyError,
|
|
82
82
|
toUint8Array
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-USKGKQZM.js";
|
|
84
84
|
import {
|
|
85
85
|
INTERNAL_ERROR_CODE,
|
|
86
86
|
RivetError,
|
|
87
87
|
UserError,
|
|
88
|
-
actorStopping,
|
|
89
88
|
decodeBridgeRivetError,
|
|
90
89
|
encodeBridgeRivetError,
|
|
91
90
|
encodeErrorForBridge,
|
|
@@ -501,7 +500,7 @@ var EnvoyConfigSchema = z.object({
|
|
|
501
500
|
version: z.number().default(() => getRivetEnvoyVersion() ?? 1),
|
|
502
501
|
// Deprecated.
|
|
503
502
|
totalSlots: z.number().default(() => getRivetTotalSlots() ?? 1e5),
|
|
504
|
-
|
|
503
|
+
envoyKey: z.string().optional()
|
|
505
504
|
});
|
|
506
505
|
|
|
507
506
|
// src/registry/config/serverless.ts
|
|
@@ -645,7 +644,7 @@ var RegistryConfigSchema = z3.object({
|
|
|
645
644
|
// // (specifically Node.js) can sometimes only be specified after the router is
|
|
646
645
|
// // created or must be imported async using `await import(...)`
|
|
647
646
|
// getUpgradeWebSocket: z.custom<GetUpgradeWebSocket>().optional(),
|
|
648
|
-
// MARK:
|
|
647
|
+
// MARK: Runner Configuration
|
|
649
648
|
/**
|
|
650
649
|
* Endpoint to connect to for Rivet Engine.
|
|
651
650
|
*
|
|
@@ -714,30 +713,30 @@ var RegistryConfigSchema = z3.object({
|
|
|
714
713
|
engineVersion: z3.string().optional().default(() => getRivetRunEngineVersion() ?? VERSION),
|
|
715
714
|
/**
|
|
716
715
|
* Starts the first-party Services actor host when RivetKit manages
|
|
717
|
-
* a local engine.
|
|
718
|
-
* or
|
|
716
|
+
* a local engine. Defaults to the local-engine decision. Set
|
|
717
|
+
* RIVET_RUN_SERVICES=0 or 1 to override it.
|
|
719
718
|
*/
|
|
720
719
|
startServices: z3.boolean().optional(),
|
|
721
720
|
/**
|
|
722
721
|
* @experimental
|
|
723
722
|
*
|
|
724
|
-
* Automatically configure serverless
|
|
723
|
+
* Automatically configure serverless envoys in the engine.
|
|
725
724
|
*/
|
|
726
725
|
configurePool: ConfigurePoolSchema.optional(),
|
|
727
726
|
// MARK: Runtime-specific
|
|
728
727
|
serverless: ServerlessConfigSchema.optional().default(
|
|
729
728
|
() => ServerlessConfigSchema.parse({})
|
|
730
729
|
),
|
|
731
|
-
|
|
730
|
+
envoy: EnvoyConfigSchema.optional().default(
|
|
732
731
|
() => EnvoyConfigSchema.parse({})
|
|
733
732
|
),
|
|
734
733
|
// MARK: Shutdown
|
|
735
734
|
/**
|
|
736
735
|
* Graceful shutdown configuration for SIGINT/SIGTERM.
|
|
737
736
|
*
|
|
738
|
-
* When a persistent
|
|
737
|
+
* When a persistent envoy is running (Mode A, started via `registry.start()`),
|
|
739
738
|
* rivetkit installs Node SIGINT/SIGTERM handlers that call into core's
|
|
740
|
-
* `shutdown()` and wait up to `gracePeriodMs` for the
|
|
739
|
+
* `shutdown()` and wait up to `gracePeriodMs` for the envoy to drain
|
|
741
740
|
* before re-raising the signal to let Node exit via its default path.
|
|
742
741
|
*
|
|
743
742
|
* Handlers are NOT installed when `handler(request)` is used alone
|
|
@@ -749,11 +748,9 @@ var RegistryConfigSchema = z3.object({
|
|
|
749
748
|
/**
|
|
750
749
|
* Wait this many milliseconds for the serve promise to resolve
|
|
751
750
|
* after calling `CoreRegistry::shutdown()`. Defaults to the
|
|
752
|
-
* engine-provided actor stop threshold once the
|
|
753
|
-
* signal-driven shutdown of a managed local development engine waits
|
|
754
|
-
* one second by default so a file watcher can restart promptly.
|
|
751
|
+
* engine-provided actor stop threshold once the envoy connects.
|
|
755
752
|
*
|
|
756
|
-
*
|
|
753
|
+
* Must be long enough for rivetkit-core to drain the envoy.
|
|
757
754
|
*/
|
|
758
755
|
gracePeriodMs: z3.number().int().min(1e3).optional(),
|
|
759
756
|
/**
|
|
@@ -789,11 +786,10 @@ var RegistryConfigSchema = z3.object({
|
|
|
789
786
|
message: "cannot specify both startEngine and endpoint"
|
|
790
787
|
});
|
|
791
788
|
}
|
|
792
|
-
if (config.configurePool) {
|
|
789
|
+
if (config.configurePool && !parsedEndpoint && !config.startEngine) {
|
|
793
790
|
ctx.addIssue({
|
|
794
791
|
code: "custom",
|
|
795
|
-
message: "
|
|
796
|
-
path: ["configurePool"]
|
|
792
|
+
message: "configurePool requires either endpoint or startEngine"
|
|
797
793
|
});
|
|
798
794
|
}
|
|
799
795
|
const localEngineEndpoint = buildEngineEndpoint(
|
|
@@ -801,7 +797,7 @@ var RegistryConfigSchema = z3.object({
|
|
|
801
797
|
config.enginePort
|
|
802
798
|
);
|
|
803
799
|
const endpoint = config.startEngine ? localEngineEndpoint : (parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint) ?? (isDevEnv ? localEngineEndpoint : void 0);
|
|
804
|
-
const startServices = config.startServices ?? getRivetRunServices();
|
|
800
|
+
const startServices = config.startServices ?? getRivetRunServices() ?? Boolean(endpoint && isLocalEngineEndpoint(endpoint));
|
|
805
801
|
const validateServerlessEndpoint = Boolean(
|
|
806
802
|
config.startEngine || parsedEndpoint
|
|
807
803
|
);
|
|
@@ -825,7 +821,6 @@ var RegistryConfigSchema = z3.object({
|
|
|
825
821
|
...config,
|
|
826
822
|
sqlite,
|
|
827
823
|
endpoint,
|
|
828
|
-
engineSpawn: !parsedEndpoint && Boolean(endpoint),
|
|
829
824
|
startServices,
|
|
830
825
|
namespace,
|
|
831
826
|
token,
|
|
@@ -855,8 +850,8 @@ function buildActorNames(config) {
|
|
|
855
850
|
);
|
|
856
851
|
}
|
|
857
852
|
var DocConfigurePoolSchema = z3.object({
|
|
858
|
-
name: z3.string().optional().describe("Name of the
|
|
859
|
-
url: z3.string().describe("URL of the serverless platform to configure
|
|
853
|
+
name: z3.string().optional().describe("Name of the runner pool."),
|
|
854
|
+
url: z3.string().describe("URL of the serverless platform to configure runners."),
|
|
860
855
|
headers: z3.record(z3.string(), z3.string()).optional().describe(
|
|
861
856
|
"Headers to include in requests to the serverless platform."
|
|
862
857
|
),
|
|
@@ -871,7 +866,7 @@ var DocConfigurePoolSchema = z3.object({
|
|
|
871
866
|
"Interval in milliseconds between metadata polls from the engine. Defaults to 10000 milliseconds (10 seconds)."
|
|
872
867
|
),
|
|
873
868
|
drainOnVersionUpgrade: z3.boolean().optional().describe(
|
|
874
|
-
"Drain
|
|
869
|
+
"Drain runners when a new version is deployed. Defaults to true."
|
|
875
870
|
)
|
|
876
871
|
}).optional();
|
|
877
872
|
var DocServerlessConfigSchema = z3.object({
|
|
@@ -890,10 +885,10 @@ var DocServerlessConfigSchema = z3.object({
|
|
|
890
885
|
}).describe("Configuration for serverless deployment mode.");
|
|
891
886
|
var DocEnvoyConfigSchema = z3.object({
|
|
892
887
|
totalSlots: z3.number().optional().describe("Total number of actor slots available. Default: 100000"),
|
|
893
|
-
poolName: z3.string().optional().describe("Name of this
|
|
894
|
-
|
|
895
|
-
version: z3.number().optional().describe("Version number of this
|
|
896
|
-
}).describe("Configuration for
|
|
888
|
+
poolName: z3.string().optional().describe("Name of this envoy pool. Default: 'default'"),
|
|
889
|
+
envoyKey: z3.string().optional().describe("Deprecated. Authentication key for the envoy."),
|
|
890
|
+
version: z3.number().optional().describe("Version number of this envoy. Default: 1")
|
|
891
|
+
}).describe("Configuration for envoy mode.");
|
|
897
892
|
var DocSqliteConfigSchema = z3.object({
|
|
898
893
|
backend: SqliteBackendSchema.optional().describe(
|
|
899
894
|
"SQLite backend to use. Native defaults to local. Wasm defaults to remote and cannot use local."
|
|
@@ -941,23 +936,19 @@ var DocRegistryConfigSchema = z3.object({
|
|
|
941
936
|
"Version of the local engine package to use. Defaults to the current RivetKit version."
|
|
942
937
|
),
|
|
943
938
|
startServices: z3.boolean().optional().describe(
|
|
944
|
-
"Starts Services when RivetKit manages a local Engine.
|
|
939
|
+
"Starts Services when RivetKit manages a local Engine. Defaults to the local-Engine decision. Set RIVET_RUN_SERVICES=0 or 1 to override."
|
|
945
940
|
),
|
|
946
941
|
configurePool: DocConfigurePoolSchema.describe(
|
|
947
|
-
"Automatically configure serverless
|
|
942
|
+
"Automatically configure serverless runners in the engine."
|
|
948
943
|
),
|
|
949
944
|
serverless: DocServerlessConfigSchema.optional(),
|
|
950
|
-
|
|
945
|
+
envoy: DocEnvoyConfigSchema.optional()
|
|
951
946
|
}).describe("RivetKit registry configuration.");
|
|
952
947
|
|
|
953
948
|
// src/registry/native.ts
|
|
954
949
|
import { VirtualWebSocket as VirtualWebSocket2 } from "@rivetkit/virtual-websocket";
|
|
955
950
|
|
|
956
951
|
// src/common/database/native-database.ts
|
|
957
|
-
function isSynchronousTransaction(transaction) {
|
|
958
|
-
const candidate = transaction;
|
|
959
|
-
return typeof candidate.commitSync === "function" && typeof candidate.rollbackSync === "function";
|
|
960
|
-
}
|
|
961
952
|
function shouldAttachNativeKvError(message) {
|
|
962
953
|
return /i\/o error|unable to open database file/i.test(message);
|
|
963
954
|
}
|
|
@@ -978,16 +969,13 @@ function toNativeBinding(arg) {
|
|
|
978
969
|
if (arg === null || arg === void 0) {
|
|
979
970
|
return { kind: "null" };
|
|
980
971
|
}
|
|
981
|
-
if (typeof arg === "bigint"
|
|
982
|
-
|
|
983
|
-
if (!Number.isSafeInteger(value)) {
|
|
984
|
-
throw new RangeError(
|
|
985
|
-
"SQLite integer bindings must be within the JavaScript safe integer range."
|
|
986
|
-
);
|
|
987
|
-
}
|
|
988
|
-
return { kind: "int", intValue: value };
|
|
972
|
+
if (typeof arg === "bigint") {
|
|
973
|
+
return { kind: "int", intValue: Number(arg) };
|
|
989
974
|
}
|
|
990
975
|
if (typeof arg === "number") {
|
|
976
|
+
if (Number.isInteger(arg)) {
|
|
977
|
+
return { kind: "int", intValue: arg };
|
|
978
|
+
}
|
|
991
979
|
return { kind: "float", floatValue: arg };
|
|
992
980
|
}
|
|
993
981
|
if (typeof arg === "string") {
|
|
@@ -1004,10 +992,9 @@ function toNativeBinding(arg) {
|
|
|
1004
992
|
function extractNamedSqliteParameters(sql) {
|
|
1005
993
|
const orderedNames = [];
|
|
1006
994
|
const seen = /* @__PURE__ */ new Set();
|
|
1007
|
-
const pattern = /
|
|
995
|
+
const pattern = /([:@$][A-Za-z_][A-Za-z0-9_]*)/g;
|
|
1008
996
|
for (const match of sql.matchAll(pattern)) {
|
|
1009
997
|
const name = match[1];
|
|
1010
|
-
if (!name) continue;
|
|
1011
998
|
if (seen.has(name)) {
|
|
1012
999
|
continue;
|
|
1013
1000
|
}
|
|
@@ -1118,52 +1105,28 @@ var NativeCloseGate = class {
|
|
|
1118
1105
|
if (this.#active > 0) {
|
|
1119
1106
|
await new Promise((resolve) => this.#waiters.push(resolve));
|
|
1120
1107
|
}
|
|
1121
|
-
await
|
|
1108
|
+
await callback();
|
|
1122
1109
|
}
|
|
1123
1110
|
};
|
|
1124
1111
|
function wrapJsNativeDatabase(database) {
|
|
1125
1112
|
const gate = new NativeCloseGate();
|
|
1126
|
-
let
|
|
1113
|
+
let closePromise;
|
|
1127
1114
|
let lastInsertRowId = null;
|
|
1128
1115
|
const executeNative = async (sql, params) => {
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
lastInsertRowId
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
const nativeParams = toNativeBindings(sql, params);
|
|
1141
|
-
const result = await database.execute(sql, nativeParams);
|
|
1142
|
-
if (result.lastInsertRowId != null) {
|
|
1143
|
-
lastInsertRowId = result.lastInsertRowId;
|
|
1144
|
-
}
|
|
1145
|
-
return result;
|
|
1146
|
-
} catch (error) {
|
|
1147
|
-
enrichNativeDatabaseError(database, error);
|
|
1148
|
-
} finally {
|
|
1149
|
-
release();
|
|
1116
|
+
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
1117
|
+
if (lastInsertRowIdColumn) {
|
|
1118
|
+
return {
|
|
1119
|
+
columns: [lastInsertRowIdColumn],
|
|
1120
|
+
rows: [[lastInsertRowId ?? 0]],
|
|
1121
|
+
changes: 0,
|
|
1122
|
+
lastInsertRowId
|
|
1123
|
+
};
|
|
1150
1124
|
}
|
|
1151
|
-
};
|
|
1152
|
-
const executeNativeSync = (sql, params) => {
|
|
1153
1125
|
const release = gate.enter();
|
|
1154
1126
|
try {
|
|
1155
1127
|
const nativeParams = toNativeBindings(sql, params);
|
|
1156
|
-
const result = database.
|
|
1157
|
-
|
|
1158
|
-
if (rowIdColumn) {
|
|
1159
|
-
return {
|
|
1160
|
-
columns: [rowIdColumn],
|
|
1161
|
-
rows: [[lastInsertRowId ?? 0]],
|
|
1162
|
-
changes: 0,
|
|
1163
|
-
lastInsertRowId
|
|
1164
|
-
};
|
|
1165
|
-
}
|
|
1166
|
-
if (result.lastInsertRowId != null) {
|
|
1128
|
+
const result = await database.execute(sql, nativeParams);
|
|
1129
|
+
if (result.lastInsertRowId !== void 0) {
|
|
1167
1130
|
lastInsertRowId = result.lastInsertRowId;
|
|
1168
1131
|
}
|
|
1169
1132
|
return result;
|
|
@@ -1191,28 +1154,9 @@ function wrapJsNativeDatabase(database) {
|
|
|
1191
1154
|
callback(row, result.columns);
|
|
1192
1155
|
}
|
|
1193
1156
|
},
|
|
1194
|
-
execSync(sql, callback) {
|
|
1195
|
-
const release = gate.enter();
|
|
1196
|
-
let result;
|
|
1197
|
-
try {
|
|
1198
|
-
result = database.execSync(sql);
|
|
1199
|
-
} catch (error) {
|
|
1200
|
-
enrichNativeDatabaseError(database, error);
|
|
1201
|
-
} finally {
|
|
1202
|
-
release();
|
|
1203
|
-
}
|
|
1204
|
-
if (callback) {
|
|
1205
|
-
for (const row of result.rows) {
|
|
1206
|
-
callback(row, result.columns);
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
},
|
|
1210
1157
|
async execute(sql, params) {
|
|
1211
1158
|
return await executeNative(sql, params);
|
|
1212
1159
|
},
|
|
1213
|
-
executeSync(sql, params) {
|
|
1214
|
-
return executeNativeSync(sql, params);
|
|
1215
|
-
},
|
|
1216
1160
|
async executeBatch(statements) {
|
|
1217
1161
|
const nativeStatements = statements.map(toNativeBatchStatement);
|
|
1218
1162
|
const release = gate.enter();
|
|
@@ -1234,7 +1178,7 @@ function wrapJsNativeDatabase(database) {
|
|
|
1234
1178
|
return transactionResults;
|
|
1235
1179
|
})();
|
|
1236
1180
|
for (const result of results) {
|
|
1237
|
-
if (result.lastInsertRowId
|
|
1181
|
+
if (result.lastInsertRowId !== void 0) {
|
|
1238
1182
|
lastInsertRowId = result.lastInsertRowId;
|
|
1239
1183
|
}
|
|
1240
1184
|
}
|
|
@@ -1262,23 +1206,7 @@ function wrapJsNativeDatabase(database) {
|
|
|
1262
1206
|
release();
|
|
1263
1207
|
}
|
|
1264
1208
|
return wrapTransaction(database, transaction, gate, (result) => {
|
|
1265
|
-
if (result.lastInsertRowId
|
|
1266
|
-
lastInsertRowId = result.lastInsertRowId;
|
|
1267
|
-
}
|
|
1268
|
-
});
|
|
1269
|
-
},
|
|
1270
|
-
beginTransactionSync(timeoutMs, name) {
|
|
1271
|
-
const release = gate.enter();
|
|
1272
|
-
let transaction;
|
|
1273
|
-
try {
|
|
1274
|
-
transaction = database.beginTransactionSync(timeoutMs, name);
|
|
1275
|
-
} catch (error) {
|
|
1276
|
-
enrichNativeDatabaseError(database, error);
|
|
1277
|
-
} finally {
|
|
1278
|
-
release();
|
|
1279
|
-
}
|
|
1280
|
-
return wrapTransaction(database, transaction, gate, (result) => {
|
|
1281
|
-
if (result.lastInsertRowId != null) {
|
|
1209
|
+
if (result.lastInsertRowId !== void 0) {
|
|
1282
1210
|
lastInsertRowId = result.lastInsertRowId;
|
|
1283
1211
|
}
|
|
1284
1212
|
});
|
|
@@ -1300,7 +1228,7 @@ function wrapJsNativeDatabase(database) {
|
|
|
1300
1228
|
release();
|
|
1301
1229
|
}
|
|
1302
1230
|
return wrapTransaction(database, transaction, gate, (result) => {
|
|
1303
|
-
if (result.lastInsertRowId
|
|
1231
|
+
if (result.lastInsertRowId !== void 0) {
|
|
1304
1232
|
lastInsertRowId = result.lastInsertRowId;
|
|
1305
1233
|
}
|
|
1306
1234
|
});
|
|
@@ -1316,37 +1244,14 @@ function wrapJsNativeDatabase(database) {
|
|
|
1316
1244
|
var _a;
|
|
1317
1245
|
return normalizeNativeMetrics((_a = database.metrics) == null ? void 0 : _a.call(database));
|
|
1318
1246
|
},
|
|
1319
|
-
async open() {
|
|
1320
|
-
const release = gate.enter();
|
|
1321
|
-
try {
|
|
1322
|
-
await database.open();
|
|
1323
|
-
} catch (error) {
|
|
1324
|
-
enrichNativeDatabaseError(database, error);
|
|
1325
|
-
} finally {
|
|
1326
|
-
release();
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
commitTicket() {
|
|
1330
|
-
return database.commitTicket();
|
|
1331
|
-
},
|
|
1332
|
-
async whenDurable(ticket) {
|
|
1333
|
-
await database.whenDurable(ticket);
|
|
1334
|
-
},
|
|
1335
|
-
abortGeneration(reason) {
|
|
1336
|
-
database.abortGeneration(reason);
|
|
1337
|
-
},
|
|
1338
1247
|
async close() {
|
|
1339
|
-
|
|
1340
|
-
await
|
|
1341
|
-
},
|
|
1342
|
-
async detachForShutdown() {
|
|
1343
|
-
terminalPromise ??= gate.close();
|
|
1344
|
-
await terminalPromise;
|
|
1248
|
+
closePromise ??= gate.close(() => database.close());
|
|
1249
|
+
await closePromise;
|
|
1345
1250
|
}
|
|
1346
1251
|
};
|
|
1347
1252
|
}
|
|
1348
1253
|
function wrapTransaction(database, transaction, gate, onExecute) {
|
|
1349
|
-
|
|
1254
|
+
return {
|
|
1350
1255
|
async exec(sql, callback) {
|
|
1351
1256
|
const release = gate.enter();
|
|
1352
1257
|
let result;
|
|
@@ -1397,61 +1302,6 @@ function wrapTransaction(database, transaction, gate, onExecute) {
|
|
|
1397
1302
|
}
|
|
1398
1303
|
}
|
|
1399
1304
|
};
|
|
1400
|
-
if (isSynchronousTransaction(transaction)) {
|
|
1401
|
-
return Object.assign(wrapped, {
|
|
1402
|
-
execSync(sql, callback) {
|
|
1403
|
-
const release = gate.enter();
|
|
1404
|
-
let result;
|
|
1405
|
-
try {
|
|
1406
|
-
result = transaction.execSync(sql);
|
|
1407
|
-
} catch (error) {
|
|
1408
|
-
enrichNativeDatabaseError(database, error);
|
|
1409
|
-
} finally {
|
|
1410
|
-
release();
|
|
1411
|
-
}
|
|
1412
|
-
if (callback) {
|
|
1413
|
-
for (const row of result.rows)
|
|
1414
|
-
callback(row, result.columns);
|
|
1415
|
-
}
|
|
1416
|
-
},
|
|
1417
|
-
executeSync(sql, params) {
|
|
1418
|
-
const release = gate.enter();
|
|
1419
|
-
try {
|
|
1420
|
-
const result = transaction.executeSync(
|
|
1421
|
-
sql,
|
|
1422
|
-
toNativeBindings(sql, params)
|
|
1423
|
-
);
|
|
1424
|
-
onExecute(result);
|
|
1425
|
-
return result;
|
|
1426
|
-
} catch (error) {
|
|
1427
|
-
enrichNativeDatabaseError(database, error);
|
|
1428
|
-
} finally {
|
|
1429
|
-
release();
|
|
1430
|
-
}
|
|
1431
|
-
},
|
|
1432
|
-
commitSync() {
|
|
1433
|
-
const release = gate.enter();
|
|
1434
|
-
try {
|
|
1435
|
-
transaction.commitSync();
|
|
1436
|
-
} catch (error) {
|
|
1437
|
-
enrichNativeDatabaseError(database, error);
|
|
1438
|
-
} finally {
|
|
1439
|
-
release();
|
|
1440
|
-
}
|
|
1441
|
-
},
|
|
1442
|
-
rollbackSync() {
|
|
1443
|
-
const release = gate.enter();
|
|
1444
|
-
try {
|
|
1445
|
-
transaction.rollbackSync();
|
|
1446
|
-
} catch (error) {
|
|
1447
|
-
enrichNativeDatabaseError(database, error);
|
|
1448
|
-
} finally {
|
|
1449
|
-
release();
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
}
|
|
1454
|
-
return wrapped;
|
|
1455
1305
|
}
|
|
1456
1306
|
function lastInsertRowIdColumnName(sql) {
|
|
1457
1307
|
const match = sql.match(
|
|
@@ -1542,12 +1392,6 @@ function getNodePath() {
|
|
|
1542
1392
|
function normalizeRuntimeSqlExecuteResult(result) {
|
|
1543
1393
|
return result;
|
|
1544
1394
|
}
|
|
1545
|
-
function servicesBinaryUnavailable(cause) {
|
|
1546
|
-
return new Error(
|
|
1547
|
-
"services.binary_unavailable: Install @rivet-dev/services yourself to run local Services, or set RIVET_SERVICES_BINARY to its executable path.",
|
|
1548
|
-
{ cause }
|
|
1549
|
-
);
|
|
1550
|
-
}
|
|
1551
1395
|
|
|
1552
1396
|
// src/registry/napi-runtime.ts
|
|
1553
1397
|
function asNativeRegistry(handle) {
|
|
@@ -1820,8 +1664,7 @@ var NapiCoreRuntime = class {
|
|
|
1820
1664
|
asNativeCancellationToken(token).cancel();
|
|
1821
1665
|
}
|
|
1822
1666
|
onCancellationTokenCancelled(token, callback) {
|
|
1823
|
-
|
|
1824
|
-
return () => listener.release();
|
|
1667
|
+
asNativeCancellationToken(token).onCancelled(callback);
|
|
1825
1668
|
}
|
|
1826
1669
|
actorState(ctx) {
|
|
1827
1670
|
return asNativeActorContext(ctx).state();
|
|
@@ -2036,9 +1879,6 @@ var NapiCoreRuntime = class {
|
|
|
2036
1879
|
async actorSqlExec(ctx, sql) {
|
|
2037
1880
|
return await this.#actorSql(ctx).exec(sql);
|
|
2038
1881
|
}
|
|
2039
|
-
actorSqlExecSync(ctx, sql) {
|
|
2040
|
-
return this.#actorSql(ctx).execSync(sql);
|
|
2041
|
-
}
|
|
2042
1882
|
async actorSqlExecute(ctx, sql, params) {
|
|
2043
1883
|
const result = await this.#actorSql(ctx).execute(
|
|
2044
1884
|
sql,
|
|
@@ -2046,13 +1886,6 @@ var NapiCoreRuntime = class {
|
|
|
2046
1886
|
);
|
|
2047
1887
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
2048
1888
|
}
|
|
2049
|
-
actorSqlExecuteSync(ctx, sql, params) {
|
|
2050
|
-
const result = this.#actorSql(ctx).executeSync(
|
|
2051
|
-
sql,
|
|
2052
|
-
toNapiSqlBindParams(params)
|
|
2053
|
-
);
|
|
2054
|
-
return normalizeRuntimeSqlExecuteResult(result);
|
|
2055
|
-
}
|
|
2056
1889
|
async actorSqlExecuteBatch(ctx, statements) {
|
|
2057
1890
|
const results = await this.#actorSql(ctx).executeBatch(
|
|
2058
1891
|
statements.map(toNapiSqlBatchStatement)
|
|
@@ -2065,18 +1898,9 @@ var NapiCoreRuntime = class {
|
|
|
2065
1898
|
name
|
|
2066
1899
|
);
|
|
2067
1900
|
}
|
|
2068
|
-
actorSqlBeginTransactionSync(ctx, timeoutMs, name) {
|
|
2069
|
-
return this.#actorSql(ctx).beginTransactionSync(
|
|
2070
|
-
timeoutMs,
|
|
2071
|
-
name
|
|
2072
|
-
);
|
|
2073
|
-
}
|
|
2074
1901
|
async actorSqlTransactionExec(transaction, sql) {
|
|
2075
1902
|
return await asNativeSqlTransaction(transaction).exec(sql);
|
|
2076
1903
|
}
|
|
2077
|
-
actorSqlTransactionExecSync(transaction, sql) {
|
|
2078
|
-
return asNativeSqlTransaction(transaction).execSync(sql);
|
|
2079
|
-
}
|
|
2080
1904
|
async actorSqlTransactionExecute(transaction, sql, params) {
|
|
2081
1905
|
const result = await asNativeSqlTransaction(transaction).execute(
|
|
2082
1906
|
sql,
|
|
@@ -2084,25 +1908,12 @@ var NapiCoreRuntime = class {
|
|
|
2084
1908
|
);
|
|
2085
1909
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
2086
1910
|
}
|
|
2087
|
-
actorSqlTransactionExecuteSync(transaction, sql, params) {
|
|
2088
|
-
const result = asNativeSqlTransaction(transaction).executeSync(
|
|
2089
|
-
sql,
|
|
2090
|
-
toNapiSqlBindParams(params)
|
|
2091
|
-
);
|
|
2092
|
-
return normalizeRuntimeSqlExecuteResult(result);
|
|
2093
|
-
}
|
|
2094
1911
|
async actorSqlTransactionCommit(transaction) {
|
|
2095
1912
|
await asNativeSqlTransaction(transaction).commit();
|
|
2096
1913
|
}
|
|
2097
|
-
actorSqlTransactionCommitSync(transaction) {
|
|
2098
|
-
asNativeSqlTransaction(transaction).commitSync();
|
|
2099
|
-
}
|
|
2100
1914
|
async actorSqlTransactionRollback(transaction) {
|
|
2101
1915
|
await asNativeSqlTransaction(transaction).rollback();
|
|
2102
1916
|
}
|
|
2103
|
-
actorSqlTransactionRollbackSync(transaction) {
|
|
2104
|
-
asNativeSqlTransaction(transaction).rollbackSync();
|
|
2105
|
-
}
|
|
2106
1917
|
async actorBeginStateTransaction(ctx, timeoutMs) {
|
|
2107
1918
|
return await this.#actorContextForOperation(ctx).beginStateTransaction(
|
|
2108
1919
|
timeoutMs
|
|
@@ -2140,18 +1951,6 @@ var NapiCoreRuntime = class {
|
|
|
2140
1951
|
var _a, _b;
|
|
2141
1952
|
return ((_b = (_a = this.#actorSql(ctx)).takeLastKvError) == null ? void 0 : _b.call(_a)) ?? null;
|
|
2142
1953
|
}
|
|
2143
|
-
async actorSqlOpen(ctx) {
|
|
2144
|
-
await this.#actorSql(ctx).open();
|
|
2145
|
-
}
|
|
2146
|
-
actorSqlCommitTicket(ctx) {
|
|
2147
|
-
return this.#actorSql(ctx).commitTicket();
|
|
2148
|
-
}
|
|
2149
|
-
actorSqlAbortGeneration(ctx, reason) {
|
|
2150
|
-
this.#actorSql(ctx).abortGeneration(reason);
|
|
2151
|
-
}
|
|
2152
|
-
async actorSqlWhenDurable(ctx, ticket) {
|
|
2153
|
-
await this.#actorSql(ctx).whenDurable(ticket);
|
|
2154
|
-
}
|
|
2155
1954
|
async actorSqlClose(ctx) {
|
|
2156
1955
|
const nativeCtx = asNativeActorContext(ctx);
|
|
2157
1956
|
if (!this.#sqlOpened.delete(nativeCtx)) {
|
|
@@ -2735,17 +2534,6 @@ function optionalWasmNumber(value) {
|
|
|
2735
2534
|
function wasmNumber(value) {
|
|
2736
2535
|
return typeof value === "bigint" ? Number(value) : value;
|
|
2737
2536
|
}
|
|
2738
|
-
function synchronousSqliteUnavailable() {
|
|
2739
|
-
throw new RivetError(
|
|
2740
|
-
"sqlite",
|
|
2741
|
-
"sync_unsupported",
|
|
2742
|
-
"Synchronous SQLite is unavailable because the actor runs on the wasm runtime.",
|
|
2743
|
-
{
|
|
2744
|
-
public: true,
|
|
2745
|
-
metadata: { runtime: "wasm" }
|
|
2746
|
-
}
|
|
2747
|
-
);
|
|
2748
|
-
}
|
|
2749
2537
|
function normalizeKvEntry(entry) {
|
|
2750
2538
|
return {
|
|
2751
2539
|
key: toBytes(entry.key),
|
|
@@ -2897,14 +2685,6 @@ var WasmCoreRuntime = class {
|
|
|
2897
2685
|
);
|
|
2898
2686
|
}
|
|
2899
2687
|
createActorFactory(callbacks, config) {
|
|
2900
|
-
if (config == null ? void 0 : config.sqliteDeferredCommits) {
|
|
2901
|
-
throw new RivetError(
|
|
2902
|
-
"sqlite",
|
|
2903
|
-
"deferred_commits_unsupported",
|
|
2904
|
-
"SQLite deferred commits require local native SQLite, but the wasm runtime uses remote SQLite.",
|
|
2905
|
-
{ metadata: { runtime: "wasm" } }
|
|
2906
|
-
);
|
|
2907
|
-
}
|
|
2908
2688
|
return callWasmSync(
|
|
2909
2689
|
() => asActorFactoryHandle2(
|
|
2910
2690
|
new this.#constructors.ActorFactory(callbacks, config)
|
|
@@ -2923,10 +2703,9 @@ var WasmCoreRuntime = class {
|
|
|
2923
2703
|
callWasmSync(() => asWasmCancellationToken(token).cancel());
|
|
2924
2704
|
}
|
|
2925
2705
|
onCancellationTokenCancelled(token, callback) {
|
|
2926
|
-
|
|
2706
|
+
callWasmSync(
|
|
2927
2707
|
() => asWasmCancellationToken(token).onCancelled(callback)
|
|
2928
2708
|
);
|
|
2929
|
-
return () => callWasmSync(() => listener.release());
|
|
2930
2709
|
}
|
|
2931
2710
|
actorState(ctx) {
|
|
2932
2711
|
return toBytes(
|
|
@@ -3181,18 +2960,12 @@ var WasmCoreRuntime = class {
|
|
|
3181
2960
|
async actorSqlExec(ctx, sql) {
|
|
3182
2961
|
return await callWasm(() => this.#actorSql(ctx).exec(sql));
|
|
3183
2962
|
}
|
|
3184
|
-
actorSqlExecSync(_ctx, _sql) {
|
|
3185
|
-
return synchronousSqliteUnavailable();
|
|
3186
|
-
}
|
|
3187
2963
|
async actorSqlExecute(ctx, sql, params) {
|
|
3188
2964
|
const result = await callWasm(
|
|
3189
2965
|
() => this.#actorSql(ctx).execute(sql, params)
|
|
3190
2966
|
);
|
|
3191
2967
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
3192
2968
|
}
|
|
3193
|
-
actorSqlExecuteSync(_ctx, _sql, _params) {
|
|
3194
|
-
return synchronousSqliteUnavailable();
|
|
3195
|
-
}
|
|
3196
2969
|
async actorSqlExecuteBatch(ctx, statements) {
|
|
3197
2970
|
const results = await callWasm(
|
|
3198
2971
|
() => this.#actorSql(ctx).executeBatch(statements)
|
|
@@ -3204,42 +2977,27 @@ var WasmCoreRuntime = class {
|
|
|
3204
2977
|
() => this.#actorSql(ctx).beginTransaction(timeoutMs, name)
|
|
3205
2978
|
);
|
|
3206
2979
|
}
|
|
3207
|
-
actorSqlBeginTransactionSync(_ctx, _timeoutMs, _name) {
|
|
3208
|
-
return synchronousSqliteUnavailable();
|
|
3209
|
-
}
|
|
3210
2980
|
async actorSqlTransactionExec(transaction, sql) {
|
|
3211
2981
|
return await callWasm(
|
|
3212
2982
|
() => transaction.exec(sql)
|
|
3213
2983
|
);
|
|
3214
2984
|
}
|
|
3215
|
-
actorSqlTransactionExecSync(_transaction, _sql) {
|
|
3216
|
-
return synchronousSqliteUnavailable();
|
|
3217
|
-
}
|
|
3218
2985
|
async actorSqlTransactionExecute(transaction, sql, params) {
|
|
3219
2986
|
const result = await callWasm(
|
|
3220
2987
|
() => transaction.execute(sql, params)
|
|
3221
2988
|
);
|
|
3222
2989
|
return normalizeRuntimeSqlExecuteResult(result);
|
|
3223
2990
|
}
|
|
3224
|
-
actorSqlTransactionExecuteSync(_transaction, _sql, _params) {
|
|
3225
|
-
return synchronousSqliteUnavailable();
|
|
3226
|
-
}
|
|
3227
2991
|
async actorSqlTransactionCommit(transaction) {
|
|
3228
2992
|
await callWasm(
|
|
3229
2993
|
() => transaction.commit()
|
|
3230
2994
|
);
|
|
3231
2995
|
}
|
|
3232
|
-
actorSqlTransactionCommitSync(_transaction) {
|
|
3233
|
-
synchronousSqliteUnavailable();
|
|
3234
|
-
}
|
|
3235
2996
|
async actorSqlTransactionRollback(transaction) {
|
|
3236
2997
|
await callWasm(
|
|
3237
2998
|
() => transaction.rollback()
|
|
3238
2999
|
);
|
|
3239
3000
|
}
|
|
3240
|
-
actorSqlTransactionRollbackSync(_transaction) {
|
|
3241
|
-
synchronousSqliteUnavailable();
|
|
3242
|
-
}
|
|
3243
3001
|
async actorBeginStateTransaction(ctx, timeoutMs) {
|
|
3244
3002
|
return await callWasm(
|
|
3245
3003
|
() => asWasmActorContext(ctx).beginStateTransaction(timeoutMs)
|
|
@@ -3275,17 +3033,6 @@ var WasmCoreRuntime = class {
|
|
|
3275
3033
|
var _a, _b;
|
|
3276
3034
|
return ((_b = (_a = this.#actorSql(ctx)).takeLastKvError) == null ? void 0 : _b.call(_a)) ?? null;
|
|
3277
3035
|
}
|
|
3278
|
-
async actorSqlOpen(_ctx) {
|
|
3279
|
-
}
|
|
3280
|
-
actorSqlCommitTicket(_ctx) {
|
|
3281
|
-
return synchronousSqliteUnavailable();
|
|
3282
|
-
}
|
|
3283
|
-
actorSqlAbortGeneration(_ctx, _reason) {
|
|
3284
|
-
synchronousSqliteUnavailable();
|
|
3285
|
-
}
|
|
3286
|
-
async actorSqlWhenDurable(_ctx, _ticket) {
|
|
3287
|
-
synchronousSqliteUnavailable();
|
|
3288
|
-
}
|
|
3289
3036
|
async actorSqlClose(ctx) {
|
|
3290
3037
|
const wasmCtx = asWasmActorContext(ctx);
|
|
3291
3038
|
const database = this.#sql.get(wasmCtx);
|
|
@@ -3751,10 +3498,9 @@ function normalizeRuntimeConfig(config, runtime) {
|
|
|
3751
3498
|
return normalizeRuntimeConfigForKind(config, loadedRuntimeKind(runtime));
|
|
3752
3499
|
}
|
|
3753
3500
|
function getNativeRuntimeState(runtime, ctx) {
|
|
3754
|
-
const runtimeState =
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
}
|
|
3501
|
+
const runtimeState = callNativeSync(
|
|
3502
|
+
() => runtime.actorRuntimeState(ctx)
|
|
3503
|
+
);
|
|
3758
3504
|
if (!runtimeState.destroyGate) {
|
|
3759
3505
|
runtimeState.destroyGate = {};
|
|
3760
3506
|
}
|
|
@@ -3767,14 +3513,6 @@ function getNativeRuntimeState(runtime, ctx) {
|
|
|
3767
3513
|
}
|
|
3768
3514
|
return runtimeState;
|
|
3769
3515
|
}
|
|
3770
|
-
function readNativeRuntimeStateBag(runtime, ctx) {
|
|
3771
|
-
return callNativeSync(
|
|
3772
|
-
() => runtime.actorRuntimeState(ctx)
|
|
3773
|
-
);
|
|
3774
|
-
}
|
|
3775
|
-
function isNativeRuntimeStateCleared(runtime, ctx) {
|
|
3776
|
-
return readNativeRuntimeStateBag(runtime, ctx).cleared === true;
|
|
3777
|
-
}
|
|
3778
3516
|
function getNativePersistState(runtime, ctx) {
|
|
3779
3517
|
const persistState = getNativeRuntimeState(runtime, ctx).persistState;
|
|
3780
3518
|
if (!persistState) {
|
|
@@ -3885,18 +3623,13 @@ function resolveNativeDestroy(runtime, ctx) {
|
|
|
3885
3623
|
gate.destroyCompletion = void 0;
|
|
3886
3624
|
}
|
|
3887
3625
|
function clearNativeRuntimeState(runtime, ctx) {
|
|
3888
|
-
var _a;
|
|
3889
|
-
const pendingSaveHandle = (_a = readNativeRuntimeStateBag(runtime, ctx).persistState) == null ? void 0 : _a.pendingSaveHandle;
|
|
3890
|
-
if (pendingSaveHandle !== void 0) {
|
|
3891
|
-
clearImmediate(pendingSaveHandle);
|
|
3892
|
-
}
|
|
3893
3626
|
callNativeSync(() => runtime.actorClearRuntimeState(ctx));
|
|
3894
|
-
readNativeRuntimeStateBag(runtime, ctx).cleared = true;
|
|
3895
3627
|
}
|
|
3896
3628
|
async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
|
|
3897
3629
|
const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
3898
3630
|
if (!drained) {
|
|
3899
|
-
await
|
|
3631
|
+
await closeNativeDatabaseClient(runtime, ctx);
|
|
3632
|
+
await closeNativeSqlDatabase(runtime, ctx);
|
|
3900
3633
|
void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
|
|
3901
3634
|
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
3902
3635
|
clearNativeRuntimeState(runtime, ctx);
|
|
@@ -3909,19 +3642,10 @@ async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrai
|
|
|
3909
3642
|
return;
|
|
3910
3643
|
}
|
|
3911
3644
|
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
3912
|
-
await
|
|
3645
|
+
await closeNativeDatabaseClient(runtime, ctx);
|
|
3646
|
+
await closeNativeSqlDatabase(runtime, ctx);
|
|
3913
3647
|
clearNativeRuntimeState(runtime, ctx);
|
|
3914
3648
|
}
|
|
3915
|
-
async function detachNativeDatabaseForShutdown(runtime, ctx) {
|
|
3916
|
-
var _a;
|
|
3917
|
-
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3918
|
-
await ((_a = runtimeState.sql) == null ? void 0 : _a.detachForShutdown());
|
|
3919
|
-
try {
|
|
3920
|
-
await closeNativeDatabaseClient(runtime, ctx);
|
|
3921
|
-
} finally {
|
|
3922
|
-
runtimeState.sql = void 0;
|
|
3923
|
-
}
|
|
3924
|
-
}
|
|
3925
3649
|
function closeNativeSqlDatabase(runtime, ctx) {
|
|
3926
3650
|
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3927
3651
|
const database = runtimeState.sql;
|
|
@@ -3942,29 +3666,15 @@ async function closeNativeDatabaseClient(runtime, ctx) {
|
|
|
3942
3666
|
await entry.client.close();
|
|
3943
3667
|
}
|
|
3944
3668
|
}
|
|
3945
|
-
function createNativeSqlTransaction(runtime, transaction) {
|
|
3946
|
-
return {
|
|
3947
|
-
exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
|
|
3948
|
-
execSync: (sql) => runtime.actorSqlTransactionExecSync(transaction, sql),
|
|
3949
|
-
execute: (sql, params) => runtime.actorSqlTransactionExecute(transaction, sql, params),
|
|
3950
|
-
executeSync: (sql, params) => runtime.actorSqlTransactionExecuteSync(transaction, sql, params),
|
|
3951
|
-
commit: () => runtime.actorSqlTransactionCommit(transaction),
|
|
3952
|
-
commitSync: () => runtime.actorSqlTransactionCommitSync(transaction),
|
|
3953
|
-
rollback: () => runtime.actorSqlTransactionRollback(transaction),
|
|
3954
|
-
rollbackSync: () => runtime.actorSqlTransactionRollbackSync(transaction)
|
|
3955
|
-
};
|
|
3956
|
-
}
|
|
3957
3669
|
function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
3958
3670
|
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3959
3671
|
const cachedDatabase = runtimeState.sql;
|
|
3960
3672
|
if (cachedDatabase) {
|
|
3961
3673
|
return cachedDatabase;
|
|
3962
3674
|
}
|
|
3963
|
-
const
|
|
3675
|
+
const database = wrapJsNativeDatabase({
|
|
3964
3676
|
exec: (sql) => runtime.actorSqlExec(ctx, sql),
|
|
3965
|
-
execSync: (sql) => runtime.actorSqlExecSync(ctx, sql),
|
|
3966
3677
|
execute: (sql, params) => runtime.actorSqlExecute(ctx, sql, params),
|
|
3967
|
-
executeSync: (sql, params) => runtime.actorSqlExecuteSync(ctx, sql, params),
|
|
3968
3678
|
executeBatch: (statements) => runtime.actorSqlExecuteBatch(ctx, statements),
|
|
3969
3679
|
beginTransaction: async (timeoutMs, name) => {
|
|
3970
3680
|
const transaction = await runtime.actorSqlBeginTransaction(
|
|
@@ -3972,15 +3682,16 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
|
3972
3682
|
timeoutMs,
|
|
3973
3683
|
name
|
|
3974
3684
|
);
|
|
3975
|
-
return
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3685
|
+
return {
|
|
3686
|
+
exec: (sql) => runtime.actorSqlTransactionExec(transaction, sql),
|
|
3687
|
+
execute: (sql, params) => runtime.actorSqlTransactionExecute(
|
|
3688
|
+
transaction,
|
|
3689
|
+
sql,
|
|
3690
|
+
params
|
|
3691
|
+
),
|
|
3692
|
+
commit: () => runtime.actorSqlTransactionCommit(transaction),
|
|
3693
|
+
rollback: () => runtime.actorSqlTransactionRollback(transaction)
|
|
3694
|
+
};
|
|
3984
3695
|
},
|
|
3985
3696
|
beginStateTransaction: async (timeoutMs, context) => {
|
|
3986
3697
|
const scope = context;
|
|
@@ -4018,13 +3729,8 @@ function getOrCreateNativeSqlDatabase(runtime, ctx) {
|
|
|
4018
3729
|
run: (sql, params) => runtime.actorSqlRun(ctx, sql, params),
|
|
4019
3730
|
metrics: () => runtime.actorSqlMetrics(ctx),
|
|
4020
3731
|
takeLastKvError: () => runtime.actorSqlTakeLastKvError(ctx),
|
|
4021
|
-
open: () => runtime.actorSqlOpen(ctx),
|
|
4022
|
-
commitTicket: () => runtime.actorSqlCommitTicket(ctx),
|
|
4023
|
-
whenDurable: (ticket) => runtime.actorSqlWhenDurable(ctx, ticket),
|
|
4024
|
-
abortGeneration: (reason) => runtime.actorSqlAbortGeneration(ctx, reason),
|
|
4025
3732
|
close: () => runtime.actorSqlClose(ctx)
|
|
4026
|
-
};
|
|
4027
|
-
const database = wrapJsNativeDatabase(bindings);
|
|
3733
|
+
});
|
|
4028
3734
|
runtimeState.sql = database;
|
|
4029
3735
|
return database;
|
|
4030
3736
|
}
|
|
@@ -5680,14 +5386,12 @@ var ActorContextHandleAdapter = class {
|
|
|
5680
5386
|
}
|
|
5681
5387
|
get abortSignal() {
|
|
5682
5388
|
if (!this.#abortSignal) {
|
|
5683
|
-
const
|
|
5684
|
-
const actorSignal = actorAbort.signal;
|
|
5389
|
+
const actorSignal = this.#createActorAbortSignal();
|
|
5685
5390
|
if (this.#dispatchCancelToken === void 0) {
|
|
5686
5391
|
this.#abortSignal = actorSignal;
|
|
5687
5392
|
} else {
|
|
5688
5393
|
const controller = new AbortController();
|
|
5689
5394
|
let cleanedUp = false;
|
|
5690
|
-
let releaseDispatchListener;
|
|
5691
5395
|
const onActorAbort = () => {
|
|
5692
5396
|
cleanup();
|
|
5693
5397
|
controller.abort();
|
|
@@ -5697,9 +5401,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5697
5401
|
return;
|
|
5698
5402
|
}
|
|
5699
5403
|
cleanedUp = true;
|
|
5700
|
-
|
|
5701
|
-
releaseDispatchListener == null ? void 0 : releaseDispatchListener();
|
|
5702
|
-
releaseDispatchListener = void 0;
|
|
5404
|
+
actorSignal.removeEventListener("abort", onActorAbort);
|
|
5703
5405
|
this.#abortSignalCleanup = void 0;
|
|
5704
5406
|
};
|
|
5705
5407
|
if (actorSignal.aborted || this.#runtime.cancellationTokenAborted(
|
|
@@ -5709,8 +5411,10 @@ var ActorContextHandleAdapter = class {
|
|
|
5709
5411
|
} else {
|
|
5710
5412
|
const dispatchCancelToken = this.#dispatchCancelToken;
|
|
5711
5413
|
this.#abortSignalCleanup = cleanup;
|
|
5712
|
-
|
|
5713
|
-
|
|
5414
|
+
actorSignal.addEventListener("abort", onActorAbort, {
|
|
5415
|
+
once: true
|
|
5416
|
+
});
|
|
5417
|
+
callNativeSync(
|
|
5714
5418
|
() => this.#runtime.onCancellationTokenCancelled(
|
|
5715
5419
|
dispatchCancelToken,
|
|
5716
5420
|
() => {
|
|
@@ -5770,12 +5474,10 @@ var ActorContextHandleAdapter = class {
|
|
|
5770
5474
|
{
|
|
5771
5475
|
open: async (requestedActorId) => {
|
|
5772
5476
|
void requestedActorId;
|
|
5773
|
-
|
|
5477
|
+
return getOrCreateNativeSqlDatabase(
|
|
5774
5478
|
this.#runtime,
|
|
5775
5479
|
this.#ctx
|
|
5776
5480
|
);
|
|
5777
|
-
await database.open();
|
|
5778
|
-
return database;
|
|
5779
5481
|
}
|
|
5780
5482
|
},
|
|
5781
5483
|
async (timeoutMs, context) => await getOrCreateNativeSqlDatabase(
|
|
@@ -6088,42 +5790,22 @@ var ActorContextHandleAdapter = class {
|
|
|
6088
5790
|
}
|
|
6089
5791
|
async dispose() {
|
|
6090
5792
|
var _a;
|
|
6091
|
-
|
|
6092
|
-
this.#flushStateChange();
|
|
6093
|
-
}
|
|
5793
|
+
this.#flushStateChange();
|
|
6094
5794
|
(_a = this.#abortSignalCleanup) == null ? void 0 : _a.call(this);
|
|
6095
5795
|
}
|
|
6096
|
-
#
|
|
6097
|
-
const runtimeState = readNativeRuntimeStateBag(
|
|
6098
|
-
this.#runtime,
|
|
6099
|
-
this.#ctx
|
|
6100
|
-
);
|
|
6101
|
-
const cached = runtimeState.actorAbort;
|
|
6102
|
-
if (cached && !cached.signal.aborted) {
|
|
6103
|
-
return cached;
|
|
6104
|
-
}
|
|
5796
|
+
#createActorAbortSignal() {
|
|
6105
5797
|
const nativeSignal = callNativeSync(
|
|
6106
5798
|
() => this.#runtime.actorAbortSignal(this.#ctx)
|
|
6107
5799
|
);
|
|
6108
5800
|
const controller = new AbortController();
|
|
6109
|
-
const actorAbort = {
|
|
6110
|
-
signal: controller.signal,
|
|
6111
|
-
listeners: /* @__PURE__ */ new Set()
|
|
6112
|
-
};
|
|
6113
|
-
const abort = () => {
|
|
6114
|
-
controller.abort();
|
|
6115
|
-
for (const listener of actorAbort.listeners) {
|
|
6116
|
-
listener();
|
|
6117
|
-
}
|
|
6118
|
-
actorAbort.listeners.clear();
|
|
6119
|
-
};
|
|
6120
5801
|
if (nativeSignal.aborted) {
|
|
6121
|
-
abort();
|
|
5802
|
+
controller.abort();
|
|
6122
5803
|
} else {
|
|
6123
|
-
nativeSignal.addEventListener("abort", abort, {
|
|
5804
|
+
nativeSignal.addEventListener("abort", () => controller.abort(), {
|
|
5805
|
+
once: true
|
|
5806
|
+
});
|
|
6124
5807
|
}
|
|
6125
|
-
|
|
6126
|
-
return actorAbort;
|
|
5808
|
+
return controller.signal;
|
|
6127
5809
|
}
|
|
6128
5810
|
#readState() {
|
|
6129
5811
|
const actorState = getNativePersistState(this.#runtime, this.#ctx);
|
|
@@ -6378,21 +6060,18 @@ function buildActorTracingConfig(actions, tracing) {
|
|
|
6378
6060
|
actions: flattenActionTraceSamplers(actions, tracing.actions)
|
|
6379
6061
|
};
|
|
6380
6062
|
}
|
|
6381
|
-
var SQLITE_DEFERRED_COMMITS = /* @__PURE__ */ Symbol.for("rivetkit.sqlite.deferredCommits");
|
|
6382
6063
|
function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
6383
|
-
var _a
|
|
6064
|
+
var _a;
|
|
6384
6065
|
const config = definition.config;
|
|
6385
6066
|
const options = config.options ?? {};
|
|
6386
6067
|
const canHibernate = options.canHibernateWebSocket;
|
|
6387
6068
|
const usesRemoteSqlite = sqliteBackendForConfig(registryConfig) === "remote";
|
|
6388
6069
|
const sqliteProfiling = (_a = config.db) == null ? void 0 : _a.sqliteProfiling;
|
|
6389
|
-
const sqliteDeferredCommits = ((_b = config.db) == null ? void 0 : _b[SQLITE_DEFERRED_COMMITS]) === true;
|
|
6390
6070
|
return {
|
|
6391
6071
|
name: options.name,
|
|
6392
6072
|
icon: options.icon,
|
|
6393
6073
|
hasDatabase: true,
|
|
6394
6074
|
remoteSqlite: usesRemoteSqlite,
|
|
6395
|
-
sqliteDeferredCommits: sqliteDeferredCommits || void 0,
|
|
6396
6075
|
sqliteProfiling,
|
|
6397
6076
|
tracing: buildActorTracingConfig(
|
|
6398
6077
|
definition.config.actions,
|
|
@@ -7088,7 +6767,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7088
6767
|
}
|
|
7089
6768
|
} finally {
|
|
7090
6769
|
resolveNativeDestroy(runtime, ctx);
|
|
7091
|
-
await
|
|
6770
|
+
await actorCtx.closeDatabase();
|
|
7092
6771
|
clearNativeRuntimeState(runtime, ctx);
|
|
7093
6772
|
await actorCtx.dispose();
|
|
7094
6773
|
}
|
|
@@ -7592,12 +7271,11 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
|
7592
7271
|
throw nativeEndpointNotConfiguredError();
|
|
7593
7272
|
}
|
|
7594
7273
|
const serveConfig = {
|
|
7595
|
-
version: config.
|
|
7274
|
+
version: config.envoy.version,
|
|
7596
7275
|
endpoint: config.endpoint,
|
|
7597
|
-
engineSpawn: config.engineSpawn,
|
|
7598
7276
|
token: config.token,
|
|
7599
7277
|
namespace: config.namespace,
|
|
7600
|
-
poolName: config.
|
|
7278
|
+
poolName: config.envoy.poolName,
|
|
7601
7279
|
startServices: resolveServicesBinary && config.startServices,
|
|
7602
7280
|
handleInspectorHttpInRuntime: true,
|
|
7603
7281
|
serverlessBasePath: config.serverless.basePath,
|
|
@@ -7618,16 +7296,14 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
|
7618
7296
|
});
|
|
7619
7297
|
}
|
|
7620
7298
|
if (resolveServicesBinary && config.startServices) {
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
serveConfig.servicesBinaryPath =
|
|
7624
|
-
}
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
}
|
|
7629
|
-
throw servicesBinaryUnavailable(error);
|
|
7630
|
-
}
|
|
7299
|
+
try {
|
|
7300
|
+
const { getServicesPath } = await loadServices();
|
|
7301
|
+
serveConfig.servicesBinaryPath = getServicesPath();
|
|
7302
|
+
} catch (error) {
|
|
7303
|
+
logger2().warn({
|
|
7304
|
+
msg: "could not resolve the Services binary; a local engine will fail with services.binary_unavailable \u2014 set RIVET_RUN_SERVICES=0 to disable Services or RIVET_SERVICES_BINARY to a local rivet-services binary",
|
|
7305
|
+
error: stringifyError(error)
|
|
7306
|
+
});
|
|
7631
7307
|
}
|
|
7632
7308
|
}
|
|
7633
7309
|
serveConfig.engineHost = config.engineHost;
|
|
@@ -7669,9 +7345,6 @@ async function buildConfiguredRegistry(config) {
|
|
|
7669
7345
|
|
|
7670
7346
|
// src/registry/index.ts
|
|
7671
7347
|
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
7672
|
-
function rejectServerless() {
|
|
7673
|
-
throw new Error("serverless is disabled in this version");
|
|
7674
|
-
}
|
|
7675
7348
|
function signalExitCode(signal) {
|
|
7676
7349
|
switch (signal) {
|
|
7677
7350
|
case "SIGINT":
|
|
@@ -7776,7 +7449,6 @@ var Registry = class {
|
|
|
7776
7449
|
*/
|
|
7777
7450
|
#ensureServerlessPoolConfigured(config) {
|
|
7778
7451
|
if (!config.configurePool) return void 0;
|
|
7779
|
-
rejectServerless();
|
|
7780
7452
|
if (!this.#configureServerlessPoolPromise) {
|
|
7781
7453
|
this.#configureServerlessPoolPromise = configureServerlessPool(
|
|
7782
7454
|
config
|
|
@@ -7801,7 +7473,6 @@ var Registry = class {
|
|
|
7801
7473
|
*/
|
|
7802
7474
|
async handler(request) {
|
|
7803
7475
|
var _a;
|
|
7804
|
-
rejectServerless();
|
|
7805
7476
|
const config = this.parseConfig();
|
|
7806
7477
|
this.#printWelcome(config, "serverless");
|
|
7807
7478
|
if (!this.#runtimeServerlessPromise) {
|
|
@@ -7963,7 +7634,6 @@ var Registry = class {
|
|
|
7963
7634
|
* ```
|
|
7964
7635
|
*/
|
|
7965
7636
|
serve() {
|
|
7966
|
-
rejectServerless();
|
|
7967
7637
|
return {
|
|
7968
7638
|
fetch: (request) => this.handler(request)
|
|
7969
7639
|
};
|
|
@@ -7988,9 +7658,6 @@ var Registry = class {
|
|
|
7988
7658
|
* ```
|
|
7989
7659
|
*/
|
|
7990
7660
|
async listen(opts = {}) {
|
|
7991
|
-
if (!opts.application) {
|
|
7992
|
-
rejectServerless();
|
|
7993
|
-
}
|
|
7994
7661
|
const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3e3;
|
|
7995
7662
|
const publicDir = opts.publicDir ?? getRivetkitPublicDir();
|
|
7996
7663
|
const config = this.parseConfig();
|
|
@@ -8091,7 +7758,6 @@ var Registry = class {
|
|
|
8091
7758
|
* Returns serverless metadata suitable for mounting in a user-owned router.
|
|
8092
7759
|
*/
|
|
8093
7760
|
async #metadataRoute() {
|
|
8094
|
-
rejectServerless();
|
|
8095
7761
|
const configured = await this.#activeConfiguredRegistry();
|
|
8096
7762
|
if (!configured) {
|
|
8097
7763
|
return new Response("registry not started\n", {
|
|
@@ -8152,18 +7818,18 @@ var Registry = class {
|
|
|
8152
7818
|
#startEnvoy(config, printWelcome) {
|
|
8153
7819
|
var _a;
|
|
8154
7820
|
if (!this.#runtimeServePromise) {
|
|
8155
|
-
const configuredEnvoyVersion = (_a = this.#config.
|
|
7821
|
+
const configuredEnvoyVersion = (_a = this.#config.envoy) == null ? void 0 : _a.version;
|
|
8156
7822
|
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : getRivetEnvoyVersion() !== void 0 ? "environment" : "default";
|
|
8157
7823
|
logger2().info({
|
|
8158
7824
|
msg: "starting rivetkit envoy",
|
|
8159
7825
|
rivetkitVersion: VERSION,
|
|
8160
|
-
envoyVersion: config.
|
|
7826
|
+
envoyVersion: config.envoy.version,
|
|
8161
7827
|
envoyVersionSource
|
|
8162
7828
|
});
|
|
8163
7829
|
if (envoyVersionSource === "default" && getNodeEnv() === "production") {
|
|
8164
7830
|
logger2().error({
|
|
8165
|
-
msg: "
|
|
8166
|
-
envoyVersion: config.
|
|
7831
|
+
msg: "envoy version defaulted because neither config.envoy.version nor RIVET_ENVOY_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
|
|
7832
|
+
envoyVersion: config.envoy.version,
|
|
8167
7833
|
envoyVersionSource
|
|
8168
7834
|
});
|
|
8169
7835
|
}
|
|
@@ -8175,10 +7841,7 @@ var Registry = class {
|
|
|
8175
7841
|
}
|
|
8176
7842
|
);
|
|
8177
7843
|
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error) => {
|
|
8178
|
-
logger2().
|
|
8179
|
-
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
8180
|
-
process.exit(1);
|
|
8181
|
-
}
|
|
7844
|
+
logger2().warn({ error }, "runtime registry serve errored");
|
|
8182
7845
|
});
|
|
8183
7846
|
this.#installSignalHandlers(config);
|
|
8184
7847
|
}
|
|
@@ -8208,7 +7871,7 @@ var Registry = class {
|
|
|
8208
7871
|
finishShutdownSignal(signal);
|
|
8209
7872
|
return;
|
|
8210
7873
|
}
|
|
8211
|
-
this.#shutdownInFlight = this.#drain(config
|
|
7874
|
+
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
8212
7875
|
logger2().warn({ err }, "shutdown error");
|
|
8213
7876
|
}).then(() => {
|
|
8214
7877
|
this.#removeSignalHandlers();
|
|
@@ -8244,18 +7907,12 @@ var Registry = class {
|
|
|
8244
7907
|
});
|
|
8245
7908
|
return this.#shutdownInFlight;
|
|
8246
7909
|
}
|
|
8247
|
-
async #drain(config
|
|
7910
|
+
async #drain(config) {
|
|
8248
7911
|
var _a;
|
|
8249
7912
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
8250
7913
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
8251
7914
|
const runtimes = /* @__PURE__ */ new Set();
|
|
8252
|
-
const
|
|
8253
|
-
let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
|
|
8254
|
-
if (gracePeriodMs === void 0) {
|
|
8255
|
-
gracePeriodMs = localDevSignal ? 1e3 : await this.#actorStopThresholdMs(
|
|
8256
|
-
modeAPromise ?? modeBPromise
|
|
8257
|
-
) ?? 30 * 60 * 1e3;
|
|
8258
|
-
}
|
|
7915
|
+
const gracePeriodMs = ((_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs) ?? await this.#actorStopThresholdMs(modeAPromise ?? modeBPromise) ?? 30 * 60 * 1e3;
|
|
8259
7916
|
const drain = async () => {
|
|
8260
7917
|
const registries = [];
|
|
8261
7918
|
if (modeAPromise !== void 0) {
|
|
@@ -8360,16 +8017,12 @@ var Registry = class {
|
|
|
8360
8017
|
);
|
|
8361
8018
|
}
|
|
8362
8019
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
);
|
|
8370
|
-
}
|
|
8371
|
-
} catch (error) {
|
|
8372
|
-
return Promise.reject(error);
|
|
8020
|
+
if (getRivetkitRuntimeMode() === "serverless") {
|
|
8021
|
+
return Promise.reject(
|
|
8022
|
+
new Error(
|
|
8023
|
+
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
8024
|
+
)
|
|
8025
|
+
);
|
|
8373
8026
|
}
|
|
8374
8027
|
const config = this.parseConfig();
|
|
8375
8028
|
if (config.runtime === "wasm") {
|