rivetkit 0.0.0-sqlite-query-metrics-v2.f5d3605 → 0.0.0-sqlite-query-metrics-v3.1dff84f
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 +60 -10
- package/dist/browser/client.js +294 -40
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +4 -2
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-HO76AEDH.cjs → chunk-22S5RCCJ.cjs} +3 -3
- package/dist/tsup/{chunk-HO76AEDH.cjs.map → chunk-22S5RCCJ.cjs.map} +1 -1
- package/dist/tsup/{chunk-EPRA2TCT.js → chunk-2CTZU7GL.js} +2 -2
- package/dist/tsup/{chunk-JI6GZ2C2.js → chunk-A2CF6PFH.js} +18 -1
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-QR6EAWEC.cjs → chunk-CWN7N5AF.cjs} +7 -7
- package/dist/tsup/{chunk-QR6EAWEC.cjs.map → chunk-CWN7N5AF.cjs.map} +1 -1
- package/dist/tsup/{chunk-3URZ4UV5.js → chunk-D7DWNYEO.js} +2 -2
- package/dist/tsup/{chunk-F7IGTKGM.js → chunk-F5PWAGS7.js} +2 -2
- package/dist/tsup/{chunk-E2CUROR3.js → chunk-FT6VRK4C.js} +2 -2
- package/dist/tsup/{chunk-FYDB45YU.cjs → chunk-HFGXV2CC.cjs} +10 -10
- package/dist/tsup/{chunk-FYDB45YU.cjs.map → chunk-HFGXV2CC.cjs.map} +1 -1
- package/dist/tsup/{chunk-D4G35VTO.js → chunk-HRKFVQPS.js} +4 -4
- package/dist/tsup/{chunk-DHL2M2E2.cjs → chunk-HXJ5U2ZI.cjs} +3 -3
- package/dist/tsup/{chunk-DHL2M2E2.cjs.map → chunk-HXJ5U2ZI.cjs.map} +1 -1
- package/dist/tsup/{chunk-L3Z3W44Q.cjs → chunk-JJUSO7GJ.cjs} +3 -3
- package/dist/tsup/{chunk-L3Z3W44Q.cjs.map → chunk-JJUSO7GJ.cjs.map} +1 -1
- package/dist/tsup/{chunk-DDS7OOVF.cjs → chunk-NG5CUXMM.cjs} +420 -182
- package/dist/tsup/chunk-NG5CUXMM.cjs.map +1 -0
- package/dist/tsup/{chunk-USKGKQZM.js → chunk-NNCL4IBC.js} +12 -7
- package/dist/tsup/chunk-NNCL4IBC.js.map +1 -0
- package/dist/tsup/{chunk-PJ5EXY6F.js → chunk-QQIFRR3B.js} +283 -45
- package/dist/tsup/chunk-QQIFRR3B.js.map +1 -0
- package/dist/tsup/{chunk-MYWZCDML.cjs → chunk-RTWH3AX3.cjs} +19 -2
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-HDVZ6YZG.cjs → chunk-SSF2XC33.cjs} +1 -1
- package/dist/tsup/chunk-SSF2XC33.cjs.map +1 -0
- package/dist/tsup/{chunk-KSP3NXGY.js → chunk-SW33HMM5.js} +3 -3
- package/dist/tsup/{chunk-6FEYCVZC.js → chunk-UXDASKP6.js} +1 -1
- package/dist/tsup/chunk-UXDASKP6.js.map +1 -0
- package/dist/tsup/{chunk-KDT56V3Y.cjs → chunk-Y4QLVCCS.cjs} +12 -7
- package/dist/tsup/chunk-Y4QLVCCS.cjs.map +1 -0
- package/dist/tsup/{chunk-JW2WPE6Z.cjs → chunk-Y5CFDGPA.cjs} +4 -4
- package/dist/tsup/{chunk-JW2WPE6Z.cjs.map → chunk-Y5CFDGPA.cjs.map} +1 -1
- package/dist/tsup/client/mod.cjs +6 -6
- package/dist/tsup/client/mod.d.cts +15 -3
- package/dist/tsup/client/mod.d.ts +15 -3
- 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-Cw_BwH_G.d.ts → config-BiiS5T5M.d.ts} +45 -12
- package/dist/tsup/{config-CkmVg2fG.d.cts → config-BnMhcPHl.d.cts} +45 -12
- package/dist/tsup/{config-D4clT6mq.d.ts → config-CBTr4IhE.d.cts} +0 -2
- package/dist/tsup/{config-D4clT6mq.d.cts → config-CBTr4IhE.d.ts} +0 -2
- package/dist/tsup/{context-_xIcgBnE.d.cts → context-DVE8XMm1.d.cts} +2 -2
- package/dist/tsup/{context-BYOKTQJi.d.ts → context-iMxXq_Lt.d.ts} +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.cjs +2 -2
- package/dist/tsup/dynamic/mod.d.cts +2 -2
- package/dist/tsup/dynamic/mod.d.ts +2 -2
- 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 +3 -3
- package/dist/tsup/inspector-tab/mod.d.ts +3 -3
- package/dist/tsup/inspector-tab/mod.js +1 -1
- package/dist/tsup/mod.cjs +298 -198
- 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 +192 -92
- 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 +25 -22
- 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 +11 -8
- package/dist/tsup/workflow/mod.js.map +1 -1
- package/package.json +12 -10
- package/src/actor/config.ts +2 -0
- package/src/actor/keys.ts +86 -0
- package/src/client/actor-conn.ts +136 -24
- package/src/client/actor-handle.ts +64 -10
- package/src/client/client.ts +6 -0
- package/src/client/config.ts +12 -1
- package/src/client/lifecycle-errors.ts +35 -2
- package/src/client/raw-utils.ts +17 -3
- package/src/client/retry-budget.ts +78 -0
- package/src/client/utils.ts +17 -2
- package/src/common/database/config.ts +0 -2
- package/src/common/database/native-database.ts +17 -6
- package/src/common/router.ts +1 -1
- package/src/engine-api/actors.ts +3 -3
- package/src/engine-client/actor-websocket-client.ts +4 -2
- package/src/engine-client/api-endpoints.ts +44 -14
- package/src/engine-client/mod.ts +2 -2
- package/src/registry/config/envoy.ts +1 -1
- package/src/registry/config/index.ts +30 -30
- package/src/registry/index.ts +66 -21
- package/src/registry/napi-runtime.ts +4 -3
- package/src/registry/native.ts +147 -48
- package/src/registry/runtime.ts +27 -10
- package/src/registry/wasm-runtime.ts +6 -3
- package/src/utils/env-vars.ts +13 -6
- package/src/workflow/driver.ts +5 -3
- package/dist/tsup/chunk-6FEYCVZC.js.map +0 -1
- package/dist/tsup/chunk-DDS7OOVF.cjs.map +0 -1
- package/dist/tsup/chunk-HDVZ6YZG.cjs.map +0 -1
- package/dist/tsup/chunk-JI6GZ2C2.js.map +0 -1
- package/dist/tsup/chunk-KDT56V3Y.cjs.map +0 -1
- package/dist/tsup/chunk-MYWZCDML.cjs.map +0 -1
- package/dist/tsup/chunk-PJ5EXY6F.js.map +0 -1
- package/dist/tsup/chunk-USKGKQZM.js.map +0 -1
- package/src/actor/config.test.ts +0 -78
- package/src/actor/keys.test.ts +0 -275
- package/src/actor/utils.test.ts +0 -48
- package/src/client/test.ts +0 -44
- package/src/client/token-provider.test.ts +0 -86
- package/src/common/database/mod.test.ts +0 -364
- package/src/common/database/native-database.test.ts +0 -220
- package/src/common/inline-websocket-adapter.test.ts +0 -51
- package/src/db/drizzle.test.ts +0 -164
- package/src/registry/config/index.test.ts +0 -25
- package/src/registry/run-handler-coordinator.test.ts +0 -252
- package/src/registry/runtime.test.ts +0 -124
- package/src/unstable/migrations.test.ts +0 -170
- package/src/utils/endpoint-parser.test.ts +0 -206
- package/src/utils.test.ts +0 -34
- package/src/workflow/driver.test.ts +0 -62
- /package/dist/tsup/{chunk-EPRA2TCT.js.map → chunk-2CTZU7GL.js.map} +0 -0
- /package/dist/tsup/{chunk-3URZ4UV5.js.map → chunk-D7DWNYEO.js.map} +0 -0
- /package/dist/tsup/{chunk-F7IGTKGM.js.map → chunk-F5PWAGS7.js.map} +0 -0
- /package/dist/tsup/{chunk-E2CUROR3.js.map → chunk-FT6VRK4C.js.map} +0 -0
- /package/dist/tsup/{chunk-D4G35VTO.js.map → chunk-HRKFVQPS.js.map} +0 -0
- /package/dist/tsup/{chunk-KSP3NXGY.js.map → chunk-SW33HMM5.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2; var _class3;
|
|
2
2
|
|
|
3
|
-
var _chunkJW2WPE6Zcjs = require('./chunk-JW2WPE6Z.cjs');
|
|
4
3
|
|
|
5
4
|
|
|
6
5
|
|
|
@@ -15,9 +14,10 @@ var _chunkJW2WPE6Zcjs = require('./chunk-JW2WPE6Z.cjs');
|
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
|
|
17
|
+
var _chunkSSF2XC33cjs = require('./chunk-SSF2XC33.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkY5CFDGPAcjs = require('./chunk-Y5CFDGPA.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -35,17 +35,17 @@ var _chunkHDVZ6YZGcjs = require('./chunk-HDVZ6YZG.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _chunkNG5CUXMMcjs = require('./chunk-NG5CUXMM.cjs');
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
var
|
|
43
|
-
require('./chunk-
|
|
42
|
+
var _chunkRTWH3AX3cjs = require('./chunk-RTWH3AX3.cjs');
|
|
43
|
+
require('./chunk-JJUSO7GJ.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _chunk22S5RCCJcjs = require('./chunk-22S5RCCJ.cjs');
|
|
49
49
|
require('./chunk-KVFIONKQ.cjs');
|
|
50
50
|
|
|
51
51
|
|
|
@@ -80,7 +80,8 @@ require('./chunk-KVFIONKQ.cjs');
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
var
|
|
83
|
+
var _chunkY4QLVCCScjs = require('./chunk-Y4QLVCCS.cjs');
|
|
84
|
+
|
|
84
85
|
|
|
85
86
|
|
|
86
87
|
|
|
@@ -97,7 +98,7 @@ var _chunkMGI2VVF6cjs = require('./chunk-MGI2VVF6.cjs');
|
|
|
97
98
|
|
|
98
99
|
// src/actor/log.ts
|
|
99
100
|
function loggerWithoutContext() {
|
|
100
|
-
return
|
|
101
|
+
return _chunkY4QLVCCScjs.getLogger.call(void 0, "actor-runtime");
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// src/actor/definition.ts
|
|
@@ -137,10 +138,10 @@ function actor(input) {
|
|
|
137
138
|
warnDeprecatedOptionKeys(
|
|
138
139
|
input == null ? void 0 : input.options
|
|
139
140
|
);
|
|
140
|
-
const config =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
const config = _chunkSSF2XC33cjs.ActorConfigSchema.parse(input);
|
|
142
|
+
_chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
|
|
143
|
+
_chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0, config.actions, config.actionInputSchemas);
|
|
144
|
+
_chunkSSF2XC33cjs.flattenActionTraceSamplers.call(void 0, config.actions, (_a = config.tracing) == null ? void 0 : _a.actions);
|
|
144
145
|
return new ActorDefinition(config);
|
|
145
146
|
}
|
|
146
147
|
function isStaticActorDefinition(definition) {
|
|
@@ -239,7 +240,7 @@ function validateSchemaSync(schemas, key, data) {
|
|
|
239
240
|
var _virtualwebsocket = require('@rivetkit/virtual-websocket');
|
|
240
241
|
var _ws = require('hono/ws');
|
|
241
242
|
function logger() {
|
|
242
|
-
return
|
|
243
|
+
return _chunkY4QLVCCScjs.getLogger.call(void 0, "inline-websocket-adapter");
|
|
243
244
|
}
|
|
244
245
|
var InlineWebSocketAdapter = class {
|
|
245
246
|
#handler;
|
|
@@ -391,7 +392,7 @@ var InlineWebSocketAdapter = class {
|
|
|
391
392
|
|
|
392
393
|
// src/registry/log.ts
|
|
393
394
|
function logger2() {
|
|
394
|
-
return
|
|
395
|
+
return _chunkY4QLVCCScjs.getLogger.call(void 0, "registry");
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
// src/serverless/configure.ts
|
|
@@ -437,8 +438,8 @@ async function configureServerlessPool(config) {
|
|
|
437
438
|
);
|
|
438
439
|
}
|
|
439
440
|
const customConfig = config.configurePool;
|
|
440
|
-
const clientConfig =
|
|
441
|
-
const dcsRes = await
|
|
441
|
+
const clientConfig = _chunkNG5CUXMMcjs.convertRegistryConfigToClientConfig.call(void 0, config);
|
|
442
|
+
const dcsRes = await _chunkNG5CUXMMcjs.getDatacenters.call(void 0, clientConfig);
|
|
442
443
|
const poolName = _nullishCoalesce(customConfig.name, () => ( "default"));
|
|
443
444
|
const serverlessToken = _nullishCoalesce(config.token, () => ( config.publicToken));
|
|
444
445
|
const headers = {
|
|
@@ -460,7 +461,7 @@ async function configureServerlessPool(config) {
|
|
|
460
461
|
metadata: _nullishCoalesce(customConfig.metadata, () => ( {})),
|
|
461
462
|
drain_on_version_upgrade: _nullishCoalesce(customConfig.drainOnVersionUpgrade, () => ( true))
|
|
462
463
|
};
|
|
463
|
-
await
|
|
464
|
+
await _chunkNG5CUXMMcjs.updateRunnerConfig.call(void 0, clientConfig, poolName, {
|
|
464
465
|
datacenters: Object.fromEntries(
|
|
465
466
|
dcsRes.datacenters.map((dc) => [dc.name, serverlessConfig])
|
|
466
467
|
)
|
|
@@ -477,7 +478,7 @@ async function configureServerlessPool(config) {
|
|
|
477
478
|
logger2().warn({
|
|
478
479
|
msg: "serverless pool configuration attempt failed",
|
|
479
480
|
attempts,
|
|
480
|
-
error:
|
|
481
|
+
error: _chunkY4QLVCCScjs.stringifyError.call(void 0, error)
|
|
481
482
|
});
|
|
482
483
|
await sleep(CONFIGURE_RETRY_DELAY_MS);
|
|
483
484
|
}
|
|
@@ -485,7 +486,7 @@ async function configureServerlessPool(config) {
|
|
|
485
486
|
logger2().error({
|
|
486
487
|
msg: "failed to configure serverless pool, validate endpoint is configured correctly then restart this process",
|
|
487
488
|
attempts,
|
|
488
|
-
error:
|
|
489
|
+
error: _chunkY4QLVCCScjs.stringifyError.call(void 0, lastError)
|
|
489
490
|
});
|
|
490
491
|
throw lastError;
|
|
491
492
|
}
|
|
@@ -496,11 +497,11 @@ var _zod = require('zod');
|
|
|
496
497
|
// src/registry/config/envoy.ts
|
|
497
498
|
var _v4 = require('zod/v4');
|
|
498
499
|
var EnvoyConfigSchema = _v4.z.object({
|
|
499
|
-
poolName: _v4.z.string().default(() => _nullishCoalesce(
|
|
500
|
-
version: _v4.z.number().default(() => _nullishCoalesce(
|
|
500
|
+
poolName: _v4.z.string().default(() => _nullishCoalesce(_chunkY4QLVCCScjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
501
|
+
version: _v4.z.number().default(() => _nullishCoalesce(_chunkY4QLVCCScjs.getRivetEnvoyVersion.call(void 0, ), () => ( 1))),
|
|
501
502
|
// Deprecated.
|
|
502
|
-
totalSlots: _v4.z.number().default(() => _nullishCoalesce(
|
|
503
|
-
|
|
503
|
+
totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkY4QLVCCScjs.getRivetTotalSlots.call(void 0, ), () => ( 1e5))),
|
|
504
|
+
nodeKey: _v4.z.string().optional()
|
|
504
505
|
});
|
|
505
506
|
|
|
506
507
|
// src/registry/config/serverless.ts
|
|
@@ -537,7 +538,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
537
538
|
*
|
|
538
539
|
* Can also be set via RIVET_PUBLIC_ENDPOINT environment variable.
|
|
539
540
|
*/
|
|
540
|
-
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
541
|
+
publicEndpoint: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY4QLVCCScjs.getRivetPublicEndpoint.call(void 0, )))),
|
|
541
542
|
/**
|
|
542
543
|
* Token that clients should use when connecting via the public endpoint.
|
|
543
544
|
*
|
|
@@ -545,7 +546,7 @@ var ServerlessConfigSchema = _v4.z.object({
|
|
|
545
546
|
*
|
|
546
547
|
* Can also be specified in the publicEndpoint URL as `https://namespace:token@host`.
|
|
547
548
|
*/
|
|
548
|
-
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
549
|
+
publicToken: _v4.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY4QLVCCScjs.getRivetPublicToken.call(void 0, ))))
|
|
549
550
|
// There is no publicNamespace config option because the frontend and backend
|
|
550
551
|
// cannot use different namespaces. The namespace is extracted from the
|
|
551
552
|
// publicEndpoint URL auth syntax if provided.
|
|
@@ -599,7 +600,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
599
600
|
* Runtime binding to use for RivetKit core.
|
|
600
601
|
* */
|
|
601
602
|
runtime: RuntimeKindSchema.optional().transform((val, ctx) => {
|
|
602
|
-
const rawRuntime = _nullishCoalesce(val, () => (
|
|
603
|
+
const rawRuntime = _nullishCoalesce(val, () => ( _chunkY4QLVCCScjs.getRivetkitRuntime.call(void 0, )));
|
|
603
604
|
if (rawRuntime === void 0) {
|
|
604
605
|
return "auto";
|
|
605
606
|
}
|
|
@@ -636,7 +637,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
636
637
|
* */
|
|
637
638
|
logging: _zod.z.object({
|
|
638
639
|
baseLogger: _zod.z.custom().optional(),
|
|
639
|
-
level:
|
|
640
|
+
level: _chunkY4QLVCCScjs.LogLevelSchema.optional()
|
|
640
641
|
}).optional().default(() => ({})),
|
|
641
642
|
// MARK: Routing
|
|
642
643
|
// // This is a function to allow for lazy configuration of upgradeWebSocket on the
|
|
@@ -644,7 +645,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
644
645
|
// // (specifically Node.js) can sometimes only be specified after the router is
|
|
645
646
|
// // created or must be imported async using `await import(...)`
|
|
646
647
|
// getUpgradeWebSocket: z.custom<GetUpgradeWebSocket>().optional(),
|
|
647
|
-
// MARK:
|
|
648
|
+
// MARK: Node Configuration
|
|
648
649
|
/**
|
|
649
650
|
* Endpoint to connect to for Rivet Engine.
|
|
650
651
|
*
|
|
@@ -654,9 +655,9 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
654
655
|
*
|
|
655
656
|
* Can also be set via RIVET_ENDPOINT environment variables.
|
|
656
657
|
*/
|
|
657
|
-
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => (
|
|
658
|
-
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
659
|
-
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => (
|
|
658
|
+
endpoint: _zod.z.string().optional().transform((val) => _nullishCoalesce(_nullishCoalesce(val, () => ( _chunkY4QLVCCScjs.getRivetEngine.call(void 0, ))), () => ( _chunkY4QLVCCScjs.getRivetEndpoint.call(void 0, )))),
|
|
659
|
+
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY4QLVCCScjs.getRivetToken.call(void 0, )))),
|
|
660
|
+
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkY4QLVCCScjs.getRivetNamespace.call(void 0, )))),
|
|
660
661
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().default({}),
|
|
661
662
|
// MARK: Client
|
|
662
663
|
// TODO:
|
|
@@ -696,47 +697,47 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
696
697
|
*
|
|
697
698
|
* Starts the full Rust engine process locally.
|
|
698
699
|
*/
|
|
699
|
-
startEngine: _zod.z.boolean().default(() =>
|
|
700
|
+
startEngine: _zod.z.boolean().default(() => _chunkY4QLVCCScjs.getRivetRunEngine.call(void 0, )),
|
|
700
701
|
/**
|
|
701
702
|
* @experimental
|
|
702
703
|
*
|
|
703
704
|
* Host to bind the spawned local engine process to.
|
|
704
705
|
*/
|
|
705
|
-
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
706
|
+
engineHost: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkY4QLVCCScjs.getRivetRunEngineHost.call(void 0, ), () => ( _chunkNG5CUXMMcjs.ENGINE_HOST))),
|
|
706
707
|
/**
|
|
707
708
|
* @experimental
|
|
708
709
|
*
|
|
709
710
|
* Port to bind the spawned local engine process to.
|
|
710
711
|
*/
|
|
711
|
-
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(
|
|
712
|
+
enginePort: _zod.z.number().int().min(1).max(65535).optional().default(() => _nullishCoalesce(_chunkY4QLVCCScjs.getRivetRunEnginePort.call(void 0, ), () => ( _chunkNG5CUXMMcjs.ENGINE_PORT))),
|
|
712
713
|
/** @experimental */
|
|
713
|
-
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
714
|
+
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkY4QLVCCScjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkY4QLVCCScjs.VERSION))),
|
|
714
715
|
/**
|
|
715
716
|
* Starts the first-party Services actor host when RivetKit manages
|
|
716
|
-
* a local engine.
|
|
717
|
-
* RIVET_RUN_SERVICES=0 or
|
|
717
|
+
* a local engine. Enabled by default for a managed local Engine. Set
|
|
718
|
+
* RIVET_RUN_SERVICES=0 or startServices: false to disable it.
|
|
718
719
|
*/
|
|
719
720
|
startServices: _zod.z.boolean().optional(),
|
|
720
721
|
/**
|
|
721
722
|
* @experimental
|
|
722
723
|
*
|
|
723
|
-
* Automatically configure serverless
|
|
724
|
+
* Automatically configure serverless nodes in the engine.
|
|
724
725
|
*/
|
|
725
726
|
configurePool: ConfigurePoolSchema.optional(),
|
|
726
727
|
// MARK: Runtime-specific
|
|
727
728
|
serverless: ServerlessConfigSchema.optional().default(
|
|
728
729
|
() => ServerlessConfigSchema.parse({})
|
|
729
730
|
),
|
|
730
|
-
|
|
731
|
+
node: EnvoyConfigSchema.optional().default(
|
|
731
732
|
() => EnvoyConfigSchema.parse({})
|
|
732
733
|
),
|
|
733
734
|
// MARK: Shutdown
|
|
734
735
|
/**
|
|
735
736
|
* Graceful shutdown configuration for SIGINT/SIGTERM.
|
|
736
737
|
*
|
|
737
|
-
* When a persistent
|
|
738
|
+
* When a persistent node is running (Mode A, started via `registry.start()`),
|
|
738
739
|
* rivetkit installs Node SIGINT/SIGTERM handlers that call into core's
|
|
739
|
-
* `shutdown()` and wait up to `gracePeriodMs` for the
|
|
740
|
+
* `shutdown()` and wait up to `gracePeriodMs` for the node to drain
|
|
740
741
|
* before re-raising the signal to let Node exit via its default path.
|
|
741
742
|
*
|
|
742
743
|
* Handlers are NOT installed when `handler(request)` is used alone
|
|
@@ -748,9 +749,12 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
748
749
|
/**
|
|
749
750
|
* Wait this many milliseconds for the serve promise to resolve
|
|
750
751
|
* after calling `CoreRegistry::shutdown()`. Defaults to the
|
|
751
|
-
* engine-provided actor stop threshold once the
|
|
752
|
+
* engine-provided actor stop threshold once the node connects. A
|
|
753
|
+
* signal-driven shutdown of a managed local development engine waits
|
|
754
|
+
* four seconds by default so actors can acknowledge stopping before
|
|
755
|
+
* a file watcher restarts the process.
|
|
752
756
|
*
|
|
753
|
-
*
|
|
757
|
+
* Set a longer period when a complete graceful node drain is required.
|
|
754
758
|
*/
|
|
755
759
|
gracePeriodMs: _zod.z.number().int().min(1e3).optional(),
|
|
756
760
|
/**
|
|
@@ -764,7 +768,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
764
768
|
}))
|
|
765
769
|
}).transform((config, ctx) => {
|
|
766
770
|
var _a, _b, _c;
|
|
767
|
-
const isDevEnv =
|
|
771
|
+
const isDevEnv = _chunkY4QLVCCScjs.isDev.call(void 0, );
|
|
768
772
|
const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
|
|
769
773
|
if (config.runtime === "wasm" && sqliteBackend === "local") {
|
|
770
774
|
ctx.addIssue({
|
|
@@ -774,7 +778,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
774
778
|
});
|
|
775
779
|
}
|
|
776
780
|
const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
|
|
777
|
-
const parsedEndpoint = config.endpoint ?
|
|
781
|
+
const parsedEndpoint = config.endpoint ? _chunkNG5CUXMMcjs.tryParseEndpoint.call(void 0, ctx, {
|
|
778
782
|
endpoint: config.endpoint,
|
|
779
783
|
path: ["endpoint"],
|
|
780
784
|
namespace: config.namespace,
|
|
@@ -786,24 +790,26 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
786
790
|
message: "cannot specify both startEngine and endpoint"
|
|
787
791
|
});
|
|
788
792
|
}
|
|
789
|
-
if (config.configurePool
|
|
793
|
+
if (config.configurePool) {
|
|
790
794
|
ctx.addIssue({
|
|
791
795
|
code: "custom",
|
|
792
|
-
message: "
|
|
796
|
+
message: "serverless is disabled in this version",
|
|
797
|
+
path: ["configurePool"]
|
|
793
798
|
});
|
|
794
799
|
}
|
|
795
|
-
const localEngineEndpoint =
|
|
800
|
+
const localEngineEndpoint = _chunkNG5CUXMMcjs.buildEngineEndpoint.call(void 0,
|
|
796
801
|
config.engineHost,
|
|
797
802
|
config.enginePort
|
|
798
803
|
);
|
|
799
804
|
const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? localEngineEndpoint : void 0)));
|
|
800
|
-
const
|
|
805
|
+
const engineSpawn = !parsedEndpoint && Boolean(endpoint);
|
|
806
|
+
const startServices = _nullishCoalesce(_nullishCoalesce(config.startServices, () => ( _chunkY4QLVCCScjs.getRivetRunServices.call(void 0, ))), () => ( engineSpawn));
|
|
801
807
|
const validateServerlessEndpoint = Boolean(
|
|
802
808
|
config.startEngine || parsedEndpoint
|
|
803
809
|
);
|
|
804
810
|
const namespace = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.namespace), () => ( config.namespace)), () => ( "default"));
|
|
805
|
-
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint &&
|
|
806
|
-
const parsedPublicEndpoint = config.serverless.publicEndpoint ?
|
|
811
|
+
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint && _chunkNG5CUXMMcjs.isLocalEngineEndpoint.call(void 0, endpoint) ? "default" : void 0)));
|
|
812
|
+
const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkNG5CUXMMcjs.tryParseEndpoint.call(void 0, ctx, {
|
|
807
813
|
endpoint: config.serverless.publicEndpoint,
|
|
808
814
|
path: ["serverless", "publicEndpoint"]
|
|
809
815
|
}) : void 0;
|
|
@@ -821,6 +827,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
821
827
|
...config,
|
|
822
828
|
sqlite,
|
|
823
829
|
endpoint,
|
|
830
|
+
engineSpawn,
|
|
824
831
|
startServices,
|
|
825
832
|
namespace,
|
|
826
833
|
token,
|
|
@@ -839,7 +846,7 @@ function buildActorNames(config) {
|
|
|
839
846
|
Object.keys(config.use).map((actorName) => {
|
|
840
847
|
const definition = config.use[actorName];
|
|
841
848
|
const options = _nullishCoalesce(definition.config.options, () => ( {}));
|
|
842
|
-
const runMeta =
|
|
849
|
+
const runMeta = _chunkSSF2XC33cjs.getRunMetadata.call(void 0, definition.config.run);
|
|
843
850
|
const metadata = {};
|
|
844
851
|
metadata.icon = _nullishCoalesce(options.icon, () => ( runMeta.icon));
|
|
845
852
|
metadata.name = _nullishCoalesce(options.name, () => ( runMeta.name));
|
|
@@ -850,8 +857,8 @@ function buildActorNames(config) {
|
|
|
850
857
|
);
|
|
851
858
|
}
|
|
852
859
|
var DocConfigurePoolSchema = _zod.z.object({
|
|
853
|
-
name: _zod.z.string().optional().describe("Name of the
|
|
854
|
-
url: _zod.z.string().describe("URL of the serverless platform to configure
|
|
860
|
+
name: _zod.z.string().optional().describe("Name of the node pool."),
|
|
861
|
+
url: _zod.z.string().describe("URL of the serverless platform to configure nodes."),
|
|
855
862
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().describe(
|
|
856
863
|
"Headers to include in requests to the serverless platform."
|
|
857
864
|
),
|
|
@@ -866,7 +873,7 @@ var DocConfigurePoolSchema = _zod.z.object({
|
|
|
866
873
|
"Interval in milliseconds between metadata polls from the engine. Defaults to 10000 milliseconds (10 seconds)."
|
|
867
874
|
),
|
|
868
875
|
drainOnVersionUpgrade: _zod.z.boolean().optional().describe(
|
|
869
|
-
"Drain
|
|
876
|
+
"Drain nodes when a new version is deployed. Defaults to true."
|
|
870
877
|
)
|
|
871
878
|
}).optional();
|
|
872
879
|
var DocServerlessConfigSchema = _zod.z.object({
|
|
@@ -885,10 +892,10 @@ var DocServerlessConfigSchema = _zod.z.object({
|
|
|
885
892
|
}).describe("Configuration for serverless deployment mode.");
|
|
886
893
|
var DocEnvoyConfigSchema = _zod.z.object({
|
|
887
894
|
totalSlots: _zod.z.number().optional().describe("Total number of actor slots available. Default: 100000"),
|
|
888
|
-
poolName: _zod.z.string().optional().describe("Name of this
|
|
889
|
-
|
|
890
|
-
version: _zod.z.number().optional().describe("Version number of this
|
|
891
|
-
}).describe("Configuration for
|
|
895
|
+
poolName: _zod.z.string().optional().describe("Name of this node pool. Default: 'default'"),
|
|
896
|
+
nodeKey: _zod.z.string().optional().describe("Deprecated. Authentication key for the node."),
|
|
897
|
+
version: _zod.z.number().optional().describe("Version number of this node. Default: 1")
|
|
898
|
+
}).describe("Configuration for node mode.");
|
|
892
899
|
var DocSqliteConfigSchema = _zod.z.object({
|
|
893
900
|
backend: SqliteBackendSchema.optional().describe(
|
|
894
901
|
"SQLite backend to use. Native defaults to local. Wasm defaults to remote and cannot use local."
|
|
@@ -907,7 +914,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
907
914
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
908
915
|
sqlite: DocSqliteConfigSchema,
|
|
909
916
|
logging: _zod.z.object({
|
|
910
|
-
level:
|
|
917
|
+
level: _chunkY4QLVCCScjs.LogLevelSchema.optional().describe(
|
|
911
918
|
"Log level for RivetKit. Default: 'warn'"
|
|
912
919
|
)
|
|
913
920
|
}).optional().describe("Logging configuration."),
|
|
@@ -936,13 +943,13 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
936
943
|
"Version of the local engine package to use. Defaults to the current RivetKit version."
|
|
937
944
|
),
|
|
938
945
|
startServices: _zod.z.boolean().optional().describe(
|
|
939
|
-
"Starts Services when RivetKit manages a local Engine.
|
|
946
|
+
"Starts Services when RivetKit manages a local Engine. Enabled by default for a managed local Engine. Set RIVET_RUN_SERVICES=0 or startServices: false to disable."
|
|
940
947
|
),
|
|
941
948
|
configurePool: DocConfigurePoolSchema.describe(
|
|
942
|
-
"Automatically configure serverless
|
|
949
|
+
"Automatically configure serverless nodes in the engine."
|
|
943
950
|
),
|
|
944
951
|
serverless: DocServerlessConfigSchema.optional(),
|
|
945
|
-
|
|
952
|
+
node: DocEnvoyConfigSchema.optional()
|
|
946
953
|
}).describe("RivetKit registry configuration.");
|
|
947
954
|
|
|
948
955
|
// src/registry/native.ts
|
|
@@ -1105,12 +1112,12 @@ var NativeCloseGate = class {
|
|
|
1105
1112
|
if (this.#active > 0) {
|
|
1106
1113
|
await new Promise((resolve) => this.#waiters.push(resolve));
|
|
1107
1114
|
}
|
|
1108
|
-
await callback();
|
|
1115
|
+
await (callback == null ? void 0 : callback());
|
|
1109
1116
|
}
|
|
1110
1117
|
};
|
|
1111
1118
|
function wrapJsNativeDatabase(database) {
|
|
1112
1119
|
const gate = new NativeCloseGate();
|
|
1113
|
-
let
|
|
1120
|
+
let terminalPromise;
|
|
1114
1121
|
let lastInsertRowId = null;
|
|
1115
1122
|
const executeNative = async (sql, params) => {
|
|
1116
1123
|
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
@@ -1245,8 +1252,12 @@ function wrapJsNativeDatabase(database) {
|
|
|
1245
1252
|
return normalizeNativeMetrics((_a = database.metrics) == null ? void 0 : _a.call(database));
|
|
1246
1253
|
},
|
|
1247
1254
|
async close() {
|
|
1248
|
-
|
|
1249
|
-
await
|
|
1255
|
+
terminalPromise ??= gate.close(() => database.close());
|
|
1256
|
+
await terminalPromise;
|
|
1257
|
+
},
|
|
1258
|
+
async detachForShutdown() {
|
|
1259
|
+
terminalPromise ??= gate.close();
|
|
1260
|
+
await terminalPromise;
|
|
1250
1261
|
}
|
|
1251
1262
|
};
|
|
1252
1263
|
}
|
|
@@ -1392,6 +1403,12 @@ function getNodePath() {
|
|
|
1392
1403
|
function normalizeRuntimeSqlExecuteResult(result) {
|
|
1393
1404
|
return result;
|
|
1394
1405
|
}
|
|
1406
|
+
function servicesBinaryUnavailable(cause) {
|
|
1407
|
+
return new Error(
|
|
1408
|
+
"services.binary_unavailable: Install @rivet-dev/services to run local Services, set RIVET_SERVICES_BINARY to its executable path, or set RIVET_RUN_SERVICES=0 to disable Services.",
|
|
1409
|
+
{ cause }
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1395
1412
|
|
|
1396
1413
|
// src/registry/napi-runtime.ts
|
|
1397
1414
|
function asNativeRegistry(handle) {
|
|
@@ -1537,7 +1554,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1537
1554
|
if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
|
|
1538
1555
|
return ownerCtx;
|
|
1539
1556
|
}
|
|
1540
|
-
const applicationSpan =
|
|
1557
|
+
const applicationSpan = _chunkNG5CUXMMcjs.readActiveTraceHeaders.call(void 0, );
|
|
1541
1558
|
if (!applicationSpan) {
|
|
1542
1559
|
return active;
|
|
1543
1560
|
}
|
|
@@ -1664,7 +1681,8 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1664
1681
|
asNativeCancellationToken(token).cancel();
|
|
1665
1682
|
}
|
|
1666
1683
|
onCancellationTokenCancelled(token, callback) {
|
|
1667
|
-
asNativeCancellationToken(token).onCancelled(callback);
|
|
1684
|
+
const listener = asNativeCancellationToken(token).onCancelled(callback);
|
|
1685
|
+
return () => listener.release();
|
|
1668
1686
|
}
|
|
1669
1687
|
actorState(ctx) {
|
|
1670
1688
|
return asNativeActorContext(ctx).state();
|
|
@@ -1740,7 +1758,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1740
1758
|
const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
|
|
1741
1759
|
return this.#invocationContext.run(
|
|
1742
1760
|
nativeCtx,
|
|
1743
|
-
() =>
|
|
1761
|
+
() => _chunkNG5CUXMMcjs.runWithActorInvocationSpan.call(void 0, span, run)
|
|
1744
1762
|
);
|
|
1745
1763
|
}
|
|
1746
1764
|
actorInvocationTraceContext(ctx) {
|
|
@@ -2115,8 +2133,8 @@ function runtimeBytesToArrayBuffer(value) {
|
|
|
2115
2133
|
function buildNativeHttpRequest(init) {
|
|
2116
2134
|
var _a;
|
|
2117
2135
|
const headers = new Headers(init.headers);
|
|
2118
|
-
const originalUrl = headers.get(
|
|
2119
|
-
headers.delete(
|
|
2136
|
+
const originalUrl = headers.get(_chunkNG5CUXMMcjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2137
|
+
headers.delete(_chunkNG5CUXMMcjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2120
2138
|
const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
|
|
2121
2139
|
const method2 = init.method.toUpperCase();
|
|
2122
2140
|
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
@@ -2195,7 +2213,7 @@ async function pumpResponseBody(reader, stream) {
|
|
|
2195
2213
|
}
|
|
2196
2214
|
} catch (error) {
|
|
2197
2215
|
try {
|
|
2198
|
-
await stream.error(
|
|
2216
|
+
await stream.error(_chunkY4QLVCCScjs.stringifyError.call(void 0, error));
|
|
2199
2217
|
} catch (streamError) {
|
|
2200
2218
|
logger2().debug({
|
|
2201
2219
|
msg: "failed to report native http response stream error",
|
|
@@ -2363,7 +2381,7 @@ var RunHandlerCoordinator = class {
|
|
|
2363
2381
|
this.#run = run;
|
|
2364
2382
|
}
|
|
2365
2383
|
get inspectorKind() {
|
|
2366
|
-
return
|
|
2384
|
+
return _chunkSSF2XC33cjs.getRunInspectorKind.call(void 0, this.#run);
|
|
2367
2385
|
}
|
|
2368
2386
|
async run(actorId, restart, callback) {
|
|
2369
2387
|
const state = this.#getOrCreate(actorId);
|
|
@@ -2471,7 +2489,7 @@ var RunHandlerCoordinator = class {
|
|
|
2471
2489
|
}
|
|
2472
2490
|
#initializeInspector(actorId, state) {
|
|
2473
2491
|
if (state.inspectorInitialized) return;
|
|
2474
|
-
const inspector =
|
|
2492
|
+
const inspector = _chunkSSF2XC33cjs.createRunInspector.call(void 0, this.#run, {
|
|
2475
2493
|
actorId,
|
|
2476
2494
|
control: this.#control(actorId, state)
|
|
2477
2495
|
});
|
|
@@ -2703,9 +2721,10 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2703
2721
|
callWasmSync(() => asWasmCancellationToken(token).cancel());
|
|
2704
2722
|
}
|
|
2705
2723
|
onCancellationTokenCancelled(token, callback) {
|
|
2706
|
-
callWasmSync(
|
|
2724
|
+
const listener = callWasmSync(
|
|
2707
2725
|
() => asWasmCancellationToken(token).onCancelled(callback)
|
|
2708
2726
|
);
|
|
2727
|
+
return () => callWasmSync(() => listener.release());
|
|
2709
2728
|
}
|
|
2710
2729
|
actorState(ctx) {
|
|
2711
2730
|
return toBytes(
|
|
@@ -3433,7 +3452,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3433
3452
|
nativeError = error;
|
|
3434
3453
|
logger2().warn({
|
|
3435
3454
|
msg: "native runtime failed to load; falling back to wasm",
|
|
3436
|
-
error:
|
|
3455
|
+
error: _chunkY4QLVCCScjs.stringifyError.call(void 0, error)
|
|
3437
3456
|
});
|
|
3438
3457
|
}
|
|
3439
3458
|
try {
|
|
@@ -3442,7 +3461,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3442
3461
|
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
3443
3462
|
"config",
|
|
3444
3463
|
"runtime_unavailable",
|
|
3445
|
-
`RivetKit could not load a core runtime. Native runtime: ${
|
|
3464
|
+
`RivetKit could not load a core runtime. Native runtime: ${_chunkY4QLVCCScjs.stringifyError.call(void 0, nativeError)} Wasm runtime: ${_chunkY4QLVCCScjs.stringifyError.call(void 0, wasmError)}`,
|
|
3446
3465
|
{
|
|
3447
3466
|
public: true,
|
|
3448
3467
|
statusCode: 500
|
|
@@ -3498,9 +3517,10 @@ function normalizeRuntimeConfig(config, runtime) {
|
|
|
3498
3517
|
return normalizeRuntimeConfigForKind(config, loadedRuntimeKind(runtime));
|
|
3499
3518
|
}
|
|
3500
3519
|
function getNativeRuntimeState(runtime, ctx) {
|
|
3501
|
-
const runtimeState =
|
|
3502
|
-
|
|
3503
|
-
|
|
3520
|
+
const runtimeState = readNativeRuntimeStateBag(runtime, ctx);
|
|
3521
|
+
if (runtimeState.cleared) {
|
|
3522
|
+
throw _chunkMGI2VVF6cjs.actorStopping.call(void 0, callNativeSync(() => runtime.actorId(ctx)));
|
|
3523
|
+
}
|
|
3504
3524
|
if (!runtimeState.destroyGate) {
|
|
3505
3525
|
runtimeState.destroyGate = {};
|
|
3506
3526
|
}
|
|
@@ -3513,6 +3533,14 @@ function getNativeRuntimeState(runtime, ctx) {
|
|
|
3513
3533
|
}
|
|
3514
3534
|
return runtimeState;
|
|
3515
3535
|
}
|
|
3536
|
+
function readNativeRuntimeStateBag(runtime, ctx) {
|
|
3537
|
+
return callNativeSync(
|
|
3538
|
+
() => runtime.actorRuntimeState(ctx)
|
|
3539
|
+
);
|
|
3540
|
+
}
|
|
3541
|
+
function isNativeRuntimeStateCleared(runtime, ctx) {
|
|
3542
|
+
return readNativeRuntimeStateBag(runtime, ctx).cleared === true;
|
|
3543
|
+
}
|
|
3516
3544
|
function getNativePersistState(runtime, ctx) {
|
|
3517
3545
|
const persistState = getNativeRuntimeState(runtime, ctx).persistState;
|
|
3518
3546
|
if (!persistState) {
|
|
@@ -3623,29 +3651,43 @@ function resolveNativeDestroy(runtime, ctx) {
|
|
|
3623
3651
|
gate.destroyCompletion = void 0;
|
|
3624
3652
|
}
|
|
3625
3653
|
function clearNativeRuntimeState(runtime, ctx) {
|
|
3654
|
+
var _a;
|
|
3655
|
+
const pendingSaveHandle = (_a = readNativeRuntimeStateBag(runtime, ctx).persistState) == null ? void 0 : _a.pendingSaveHandle;
|
|
3656
|
+
if (pendingSaveHandle !== void 0) {
|
|
3657
|
+
clearImmediate(pendingSaveHandle);
|
|
3658
|
+
}
|
|
3626
3659
|
callNativeSync(() => runtime.actorClearRuntimeState(ctx));
|
|
3660
|
+
readNativeRuntimeStateBag(runtime, ctx).cleared = true;
|
|
3627
3661
|
}
|
|
3628
3662
|
async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
|
|
3629
3663
|
const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
3630
3664
|
if (!drained) {
|
|
3631
|
-
await
|
|
3632
|
-
await closeNativeSqlDatabase(runtime, ctx);
|
|
3665
|
+
await detachNativeDatabaseForShutdown(runtime, ctx);
|
|
3633
3666
|
void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
|
|
3634
3667
|
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
3635
3668
|
clearNativeRuntimeState(runtime, ctx);
|
|
3636
3669
|
}).catch((error) => {
|
|
3637
3670
|
logger2().warn({
|
|
3638
3671
|
msg: "deferred native sleep cleanup failed",
|
|
3639
|
-
error:
|
|
3672
|
+
error: _chunkY4QLVCCScjs.stringifyError.call(void 0, error)
|
|
3640
3673
|
});
|
|
3641
3674
|
});
|
|
3642
3675
|
return;
|
|
3643
3676
|
}
|
|
3644
3677
|
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
3645
|
-
await
|
|
3646
|
-
await closeNativeSqlDatabase(runtime, ctx);
|
|
3678
|
+
await detachNativeDatabaseForShutdown(runtime, ctx);
|
|
3647
3679
|
clearNativeRuntimeState(runtime, ctx);
|
|
3648
3680
|
}
|
|
3681
|
+
async function detachNativeDatabaseForShutdown(runtime, ctx) {
|
|
3682
|
+
var _a;
|
|
3683
|
+
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3684
|
+
await ((_a = runtimeState.sql) == null ? void 0 : _a.detachForShutdown());
|
|
3685
|
+
try {
|
|
3686
|
+
await closeNativeDatabaseClient(runtime, ctx);
|
|
3687
|
+
} finally {
|
|
3688
|
+
runtimeState.sql = void 0;
|
|
3689
|
+
}
|
|
3690
|
+
}
|
|
3649
3691
|
function closeNativeSqlDatabase(runtime, ctx) {
|
|
3650
3692
|
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3651
3693
|
const database = runtimeState.sql;
|
|
@@ -3799,10 +3841,10 @@ function decodeValue(value) {
|
|
|
3799
3841
|
if (!value || value.length === 0) {
|
|
3800
3842
|
return void 0;
|
|
3801
3843
|
}
|
|
3802
|
-
return
|
|
3844
|
+
return _chunkY4QLVCCScjs.decodeCborCompat.call(void 0, value);
|
|
3803
3845
|
}
|
|
3804
3846
|
function encodeValue(value) {
|
|
3805
|
-
return
|
|
3847
|
+
return _chunkY4QLVCCScjs.encodeCborCompat.call(void 0, value);
|
|
3806
3848
|
}
|
|
3807
3849
|
function normalizeArgs(value) {
|
|
3808
3850
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
@@ -3838,7 +3880,7 @@ function isStructuredBridgeError(error) {
|
|
|
3838
3880
|
return _chunkMGI2VVF6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
3839
3881
|
}
|
|
3840
3882
|
function encodeNativeCallbackError(error) {
|
|
3841
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
3883
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkY4QLVCCScjs.deconstructError.call(void 0, error, true);
|
|
3842
3884
|
const { encoded, droppedMetadataCause } = _chunkMGI2VVF6cjs.encodeBridgeRivetError.call(void 0, structuredError);
|
|
3843
3885
|
if (droppedMetadataCause !== void 0) {
|
|
3844
3886
|
logger2().warn(
|
|
@@ -3900,7 +3942,7 @@ function decodeWorkflowCbor(data) {
|
|
|
3900
3942
|
return null;
|
|
3901
3943
|
}
|
|
3902
3944
|
try {
|
|
3903
|
-
return
|
|
3945
|
+
return _chunkY4QLVCCScjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
3904
3946
|
} catch (e3) {
|
|
3905
3947
|
return null;
|
|
3906
3948
|
}
|
|
@@ -4013,7 +4055,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
4013
4055
|
if (data === null) {
|
|
4014
4056
|
return null;
|
|
4015
4057
|
}
|
|
4016
|
-
const history =
|
|
4058
|
+
const history = _chunkY5CFDGPAcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
4017
4059
|
return jsonSafe({
|
|
4018
4060
|
nameRegistry: [...history.nameRegistry],
|
|
4019
4061
|
entries: history.entries.map((entry) => ({
|
|
@@ -4112,7 +4154,7 @@ var NativeConnAdapter = class {
|
|
|
4112
4154
|
this.#ctx = ctx;
|
|
4113
4155
|
this.#queueHibernationRemoval = queueHibernationRemoval;
|
|
4114
4156
|
this.#assertCanMutateState = assertCanMutateState;
|
|
4115
|
-
this[
|
|
4157
|
+
this[_chunkSSF2XC33cjs.CONN_STATE_MANAGER_SYMBOL] = {
|
|
4116
4158
|
stateEnabled: true,
|
|
4117
4159
|
get state() {
|
|
4118
4160
|
return thisConn.state;
|
|
@@ -4129,7 +4171,7 @@ var NativeConnAdapter = class {
|
|
|
4129
4171
|
decodeValue(this.#runtime.connParams(this.#conn))
|
|
4130
4172
|
);
|
|
4131
4173
|
}
|
|
4132
|
-
[
|
|
4174
|
+
[_chunkSSF2XC33cjs.RAW_STATE_SYMBOL]() {
|
|
4133
4175
|
return this.#readState();
|
|
4134
4176
|
}
|
|
4135
4177
|
get state() {
|
|
@@ -4159,7 +4201,7 @@ var NativeConnAdapter = class {
|
|
|
4159
4201
|
},
|
|
4160
4202
|
(newValue) => {
|
|
4161
4203
|
assertCurrentState();
|
|
4162
|
-
|
|
4204
|
+
_chunkY4QLVCCScjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4163
4205
|
}
|
|
4164
4206
|
);
|
|
4165
4207
|
}
|
|
@@ -4167,7 +4209,7 @@ var NativeConnAdapter = class {
|
|
|
4167
4209
|
var _a;
|
|
4168
4210
|
(_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
|
|
4169
4211
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
4170
|
-
|
|
4212
|
+
_chunkY4QLVCCScjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
4171
4213
|
this.#writeState(nextValue, { writeNative: true });
|
|
4172
4214
|
}
|
|
4173
4215
|
initializeState(value) {
|
|
@@ -4364,7 +4406,7 @@ var NativeKvAdapter = class {
|
|
|
4364
4406
|
const value = await callNative(
|
|
4365
4407
|
() => this.#runtime.actorKvGet(
|
|
4366
4408
|
this.#ctx,
|
|
4367
|
-
|
|
4409
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
|
|
4368
4410
|
)
|
|
4369
4411
|
);
|
|
4370
4412
|
return value ? decodeNativeKvValue(new Uint8Array(value), options) : null;
|
|
@@ -4373,7 +4415,7 @@ var NativeKvAdapter = class {
|
|
|
4373
4415
|
await callNative(
|
|
4374
4416
|
() => this.#runtime.actorKvPut(
|
|
4375
4417
|
this.#ctx,
|
|
4376
|
-
|
|
4418
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key)),
|
|
4377
4419
|
toRuntimeBytes(value)
|
|
4378
4420
|
)
|
|
4379
4421
|
);
|
|
@@ -4382,7 +4424,7 @@ var NativeKvAdapter = class {
|
|
|
4382
4424
|
await callNative(
|
|
4383
4425
|
() => this.#runtime.actorKvDelete(
|
|
4384
4426
|
this.#ctx,
|
|
4385
|
-
|
|
4427
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
|
|
4386
4428
|
)
|
|
4387
4429
|
);
|
|
4388
4430
|
}
|
|
@@ -4390,8 +4432,8 @@ var NativeKvAdapter = class {
|
|
|
4390
4432
|
await callNative(
|
|
4391
4433
|
() => this.#runtime.actorKvDeleteRange(
|
|
4392
4434
|
this.#ctx,
|
|
4393
|
-
|
|
4394
|
-
|
|
4435
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(start)),
|
|
4436
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(end))
|
|
4395
4437
|
)
|
|
4396
4438
|
);
|
|
4397
4439
|
}
|
|
@@ -4404,7 +4446,7 @@ var NativeKvAdapter = class {
|
|
|
4404
4446
|
const entries = await callNative(
|
|
4405
4447
|
() => this.#runtime.actorKvListPrefix(
|
|
4406
4448
|
this.#ctx,
|
|
4407
|
-
|
|
4449
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0,
|
|
4408
4450
|
encodeNativeKvUserKey(
|
|
4409
4451
|
prefix,
|
|
4410
4452
|
options == null ? void 0 : options.keyType
|
|
@@ -4418,7 +4460,7 @@ var NativeKvAdapter = class {
|
|
|
4418
4460
|
);
|
|
4419
4461
|
return entries.map((entry) => [
|
|
4420
4462
|
decodeNativeKvKey(
|
|
4421
|
-
|
|
4463
|
+
_chunkRTWH3AX3cjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
|
|
4422
4464
|
options == null ? void 0 : options.keyType
|
|
4423
4465
|
),
|
|
4424
4466
|
decodeNativeKvValue(new Uint8Array(entry.value), options)
|
|
@@ -4437,13 +4479,13 @@ var NativeKvAdapter = class {
|
|
|
4437
4479
|
const entries = await callNative(
|
|
4438
4480
|
() => this.#runtime.actorKvListRange(
|
|
4439
4481
|
this.#ctx,
|
|
4440
|
-
|
|
4482
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0,
|
|
4441
4483
|
encodeNativeKvUserKey(
|
|
4442
4484
|
start,
|
|
4443
4485
|
options == null ? void 0 : options.keyType
|
|
4444
4486
|
)
|
|
4445
4487
|
),
|
|
4446
|
-
|
|
4488
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0,
|
|
4447
4489
|
encodeNativeKvUserKey(
|
|
4448
4490
|
end,
|
|
4449
4491
|
options == null ? void 0 : options.keyType
|
|
@@ -4457,7 +4499,7 @@ var NativeKvAdapter = class {
|
|
|
4457
4499
|
);
|
|
4458
4500
|
return entries.map((entry) => [
|
|
4459
4501
|
decodeNativeKvKey(
|
|
4460
|
-
|
|
4502
|
+
_chunkRTWH3AX3cjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
|
|
4461
4503
|
options == null ? void 0 : options.keyType
|
|
4462
4504
|
),
|
|
4463
4505
|
decodeNativeKvValue(new Uint8Array(entry.value), options)
|
|
@@ -5186,7 +5228,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5186
5228
|
this.#databaseProvider = databaseProvider;
|
|
5187
5229
|
}
|
|
5188
5230
|
this.#request = request;
|
|
5189
|
-
this[
|
|
5231
|
+
this[_chunkSSF2XC33cjs.ACTOR_CONTEXT_INTERNAL_SYMBOL] = new NativeWorkflowRuntimeAdapter(
|
|
5190
5232
|
this,
|
|
5191
5233
|
() => this.#logByInvocationScope.delete(
|
|
5192
5234
|
_nullishCoalesce(this.#runtime.currentInvocationScope(), () => ( NO_INVOCATION_SCOPE))
|
|
@@ -5219,7 +5261,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5219
5261
|
}
|
|
5220
5262
|
throw databaseClientNotReadyError();
|
|
5221
5263
|
}
|
|
5222
|
-
[
|
|
5264
|
+
[_chunkSSF2XC33cjs.RAW_STATE_SYMBOL]() {
|
|
5223
5265
|
if (!this.#stateEnabled) {
|
|
5224
5266
|
throw stateNotEnabledError();
|
|
5225
5267
|
}
|
|
@@ -5246,7 +5288,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5246
5288
|
},
|
|
5247
5289
|
(newValue) => {
|
|
5248
5290
|
assertCurrentState();
|
|
5249
|
-
|
|
5291
|
+
_chunkY4QLVCCScjs.assertJsonCompatValue.call(void 0, newValue);
|
|
5250
5292
|
}
|
|
5251
5293
|
);
|
|
5252
5294
|
}
|
|
@@ -5258,7 +5300,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5258
5300
|
}
|
|
5259
5301
|
this.#assertCanMutateState();
|
|
5260
5302
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
5261
|
-
|
|
5303
|
+
_chunkY4QLVCCScjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
5262
5304
|
this.#writeState(nextValue, { scheduleSave: true });
|
|
5263
5305
|
}
|
|
5264
5306
|
initializeState(value) {
|
|
@@ -5386,12 +5428,14 @@ var ActorContextHandleAdapter = class {
|
|
|
5386
5428
|
}
|
|
5387
5429
|
get abortSignal() {
|
|
5388
5430
|
if (!this.#abortSignal) {
|
|
5389
|
-
const
|
|
5431
|
+
const actorAbort = this.#actorAbort();
|
|
5432
|
+
const actorSignal = actorAbort.signal;
|
|
5390
5433
|
if (this.#dispatchCancelToken === void 0) {
|
|
5391
5434
|
this.#abortSignal = actorSignal;
|
|
5392
5435
|
} else {
|
|
5393
5436
|
const controller = new AbortController();
|
|
5394
5437
|
let cleanedUp = false;
|
|
5438
|
+
let releaseDispatchListener;
|
|
5395
5439
|
const onActorAbort = () => {
|
|
5396
5440
|
cleanup();
|
|
5397
5441
|
controller.abort();
|
|
@@ -5401,7 +5445,9 @@ var ActorContextHandleAdapter = class {
|
|
|
5401
5445
|
return;
|
|
5402
5446
|
}
|
|
5403
5447
|
cleanedUp = true;
|
|
5404
|
-
|
|
5448
|
+
actorAbort.listeners.delete(onActorAbort);
|
|
5449
|
+
releaseDispatchListener == null ? void 0 : releaseDispatchListener();
|
|
5450
|
+
releaseDispatchListener = void 0;
|
|
5405
5451
|
this.#abortSignalCleanup = void 0;
|
|
5406
5452
|
};
|
|
5407
5453
|
if (actorSignal.aborted || this.#runtime.cancellationTokenAborted(
|
|
@@ -5411,10 +5457,8 @@ var ActorContextHandleAdapter = class {
|
|
|
5411
5457
|
} else {
|
|
5412
5458
|
const dispatchCancelToken = this.#dispatchCancelToken;
|
|
5413
5459
|
this.#abortSignalCleanup = cleanup;
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
});
|
|
5417
|
-
callNativeSync(
|
|
5460
|
+
actorAbort.listeners.add(onActorAbort);
|
|
5461
|
+
releaseDispatchListener = callNativeSync(
|
|
5418
5462
|
() => this.#runtime.onCancellationTokenCancelled(
|
|
5419
5463
|
dispatchCancelToken,
|
|
5420
5464
|
() => {
|
|
@@ -5470,7 +5514,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5470
5514
|
log: {
|
|
5471
5515
|
debug: (obj) => logger2().debug(obj)
|
|
5472
5516
|
},
|
|
5473
|
-
nativeDatabaseProvider:
|
|
5517
|
+
nativeDatabaseProvider: _chunk22S5RCCJcjs.registerNativeStateTransactionOpener.call(void 0,
|
|
5474
5518
|
{
|
|
5475
5519
|
open: async (requestedActorId) => {
|
|
5476
5520
|
void requestedActorId;
|
|
@@ -5493,7 +5537,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5493
5537
|
return this.#db;
|
|
5494
5538
|
}
|
|
5495
5539
|
#bindDatabaseClient(client) {
|
|
5496
|
-
return
|
|
5540
|
+
return _chunk22S5RCCJcjs.bindNativeStateTransactionContext.call(void 0, client, {
|
|
5497
5541
|
enter: async () => await this.#enterStateTransaction(),
|
|
5498
5542
|
exit: (scope) => this.#exitStateTransaction(
|
|
5499
5543
|
scope
|
|
@@ -5697,7 +5741,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5697
5741
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
5698
5742
|
logger2().warn({
|
|
5699
5743
|
msg: "keepAwake promise rejected",
|
|
5700
|
-
error:
|
|
5744
|
+
error: _chunkY4QLVCCScjs.stringifyError.call(void 0, error)
|
|
5701
5745
|
});
|
|
5702
5746
|
}).then(() => null);
|
|
5703
5747
|
try {
|
|
@@ -5790,22 +5834,42 @@ var ActorContextHandleAdapter = class {
|
|
|
5790
5834
|
}
|
|
5791
5835
|
async dispose() {
|
|
5792
5836
|
var _a;
|
|
5793
|
-
this.#
|
|
5837
|
+
if (!isNativeRuntimeStateCleared(this.#runtime, this.#ctx)) {
|
|
5838
|
+
this.#flushStateChange();
|
|
5839
|
+
}
|
|
5794
5840
|
(_a = this.#abortSignalCleanup) == null ? void 0 : _a.call(this);
|
|
5795
5841
|
}
|
|
5796
|
-
#
|
|
5842
|
+
#actorAbort() {
|
|
5843
|
+
const runtimeState = readNativeRuntimeStateBag(
|
|
5844
|
+
this.#runtime,
|
|
5845
|
+
this.#ctx
|
|
5846
|
+
);
|
|
5847
|
+
const cached = runtimeState.actorAbort;
|
|
5848
|
+
if (cached && !cached.signal.aborted) {
|
|
5849
|
+
return cached;
|
|
5850
|
+
}
|
|
5797
5851
|
const nativeSignal = callNativeSync(
|
|
5798
5852
|
() => this.#runtime.actorAbortSignal(this.#ctx)
|
|
5799
5853
|
);
|
|
5800
5854
|
const controller = new AbortController();
|
|
5801
|
-
|
|
5855
|
+
const actorAbort = {
|
|
5856
|
+
signal: controller.signal,
|
|
5857
|
+
listeners: /* @__PURE__ */ new Set()
|
|
5858
|
+
};
|
|
5859
|
+
const abort = () => {
|
|
5802
5860
|
controller.abort();
|
|
5861
|
+
for (const listener of actorAbort.listeners) {
|
|
5862
|
+
listener();
|
|
5863
|
+
}
|
|
5864
|
+
actorAbort.listeners.clear();
|
|
5865
|
+
};
|
|
5866
|
+
if (nativeSignal.aborted) {
|
|
5867
|
+
abort();
|
|
5803
5868
|
} else {
|
|
5804
|
-
nativeSignal.addEventListener("abort",
|
|
5805
|
-
once: true
|
|
5806
|
-
});
|
|
5869
|
+
nativeSignal.addEventListener("abort", abort, { once: true });
|
|
5807
5870
|
}
|
|
5808
|
-
|
|
5871
|
+
runtimeState.actorAbort = actorAbort;
|
|
5872
|
+
return actorAbort;
|
|
5809
5873
|
}
|
|
5810
5874
|
#readState() {
|
|
5811
5875
|
const actorState = getNativePersistState(this.#runtime, this.#ctx);
|
|
@@ -6057,7 +6121,7 @@ function buildActorTracingConfig(actions, tracing) {
|
|
|
6057
6121
|
if (tracing === void 0) return void 0;
|
|
6058
6122
|
return {
|
|
6059
6123
|
sampler: tracing.sampler,
|
|
6060
|
-
actions:
|
|
6124
|
+
actions: _chunkSSF2XC33cjs.flattenActionTraceSamplers.call(void 0, actions, tracing.actions)
|
|
6061
6125
|
};
|
|
6062
6126
|
}
|
|
6063
6127
|
function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
@@ -6099,7 +6163,7 @@ function buildActorConfig(definition, registryConfig, runtimeKind) {
|
|
|
6099
6163
|
maxOutgoingMessageSize: registryConfig.maxOutgoingMessageSize,
|
|
6100
6164
|
preloadMaxWorkflowBytes: options.preloadMaxWorkflowBytes,
|
|
6101
6165
|
preloadMaxConnectionsBytes: options.preloadMaxConnectionsBytes,
|
|
6102
|
-
actions: Object.keys(
|
|
6166
|
+
actions: Object.keys(_chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions)).sort().map((name) => ({ name })),
|
|
6103
6167
|
inspectorTabs: buildInspectorTabs(config.inspector, runtimeKind)
|
|
6104
6168
|
};
|
|
6105
6169
|
}
|
|
@@ -6175,10 +6239,10 @@ function validateInspectorTabSource(tabId, resolved) {
|
|
|
6175
6239
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
6176
6240
|
var _a;
|
|
6177
6241
|
const config = definition.config;
|
|
6178
|
-
const databaseProvider = _nullishCoalesce(config.db, () => (
|
|
6179
|
-
const actionHandlers =
|
|
6242
|
+
const databaseProvider = _nullishCoalesce(config.db, () => ( _chunk22S5RCCJcjs.db.call(void 0, )));
|
|
6243
|
+
const actionHandlers = _chunkSSF2XC33cjs.flattenActionHandlers.call(void 0, config.actions);
|
|
6180
6244
|
const schemaConfig = {
|
|
6181
|
-
actionInputSchemas:
|
|
6245
|
+
actionInputSchemas: _chunkSSF2XC33cjs.flattenActionInputSchemas.call(void 0,
|
|
6182
6246
|
config.actions,
|
|
6183
6247
|
config.actionInputSchemas
|
|
6184
6248
|
),
|
|
@@ -6186,9 +6250,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6186
6250
|
events: config.events,
|
|
6187
6251
|
queues: config.queues
|
|
6188
6252
|
};
|
|
6189
|
-
const createClient = (ctx) =>
|
|
6190
|
-
new (0,
|
|
6191
|
-
|
|
6253
|
+
const createClient = (ctx) => _chunkNG5CUXMMcjs.createClientWithDriver.call(void 0,
|
|
6254
|
+
new (0, _chunkNG5CUXMMcjs.RemoteEngineControlClient)(
|
|
6255
|
+
_chunkNG5CUXMMcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
6192
6256
|
),
|
|
6193
6257
|
{
|
|
6194
6258
|
encoding: "bare",
|
|
@@ -6200,13 +6264,13 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6200
6264
|
)
|
|
6201
6265
|
}
|
|
6202
6266
|
);
|
|
6203
|
-
const run =
|
|
6204
|
-
const runHandlerCoordinator =
|
|
6267
|
+
const run = _chunkSSF2XC33cjs.getRunFunction.call(void 0, config.run);
|
|
6268
|
+
const runHandlerCoordinator = _chunkSSF2XC33cjs.getRunInspectorKind.call(void 0, config.run) === "workflow" ? new RunHandlerCoordinator(config.run) : void 0;
|
|
6205
6269
|
const getNativeWorkflowInspector = (ctx) => {
|
|
6206
6270
|
var _a2, _b;
|
|
6207
6271
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6208
6272
|
const restart = () => callNativeSync(() => runtime.actorRestartRunHandler(ctx));
|
|
6209
|
-
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b =
|
|
6273
|
+
return _nullishCoalesce(((_a2 = runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.getInspector(actorId, restart)) == null ? void 0 : _a2.workflow), () => ( ((_b = _chunkSSF2XC33cjs.getRunInspectorConfig.call(void 0, config.run, actorId)) == null ? void 0 : _b.workflow)));
|
|
6210
6274
|
};
|
|
6211
6275
|
const onStateChange = typeof config.onStateChange === "function" ? (actorCtx, nextState) => {
|
|
6212
6276
|
config.onStateChange(actorCtx, nextState);
|
|
@@ -6380,7 +6444,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6380
6444
|
400
|
|
6381
6445
|
);
|
|
6382
6446
|
}
|
|
6383
|
-
const cbor =
|
|
6447
|
+
const cbor = _chunkY4QLVCCScjs.encodeCborCompat.call(void 0,
|
|
6384
6448
|
_nullishCoalesce(body.body, () => ( null))
|
|
6385
6449
|
);
|
|
6386
6450
|
const message = await runtime.actorQueueSend(ctx, name, cbor);
|
|
@@ -6748,7 +6812,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6748
6812
|
);
|
|
6749
6813
|
} finally {
|
|
6750
6814
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6751
|
-
|
|
6815
|
+
_chunkSSF2XC33cjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6752
6816
|
await actorCtx.dispose();
|
|
6753
6817
|
}
|
|
6754
6818
|
}
|
|
@@ -6760,14 +6824,14 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6760
6824
|
const actorCtx = makeActorCtx(ctx);
|
|
6761
6825
|
const actorId = callNativeSync(() => runtime.actorId(ctx));
|
|
6762
6826
|
runHandlerCoordinator == null ? void 0 : runHandlerCoordinator.destroy(actorId);
|
|
6763
|
-
|
|
6827
|
+
_chunkSSF2XC33cjs.disposeRunInspector.call(void 0, config.run, actorId);
|
|
6764
6828
|
try {
|
|
6765
6829
|
if (typeof config.onDestroy === "function") {
|
|
6766
6830
|
await config.onDestroy(actorCtx);
|
|
6767
6831
|
}
|
|
6768
6832
|
} finally {
|
|
6769
6833
|
resolveNativeDestroy(runtime, ctx);
|
|
6770
|
-
await
|
|
6834
|
+
await detachNativeDatabaseForShutdown(runtime, ctx);
|
|
6771
6835
|
clearNativeRuntimeState(runtime, ctx);
|
|
6772
6836
|
await actorCtx.dispose();
|
|
6773
6837
|
}
|
|
@@ -6977,7 +7041,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6977
7041
|
...request,
|
|
6978
7042
|
abortController: requestAbortController
|
|
6979
7043
|
});
|
|
6980
|
-
const rawConnParams = handlerRequest.headers.get(
|
|
7044
|
+
const rawConnParams = handlerRequest.headers.get(_chunkNG5CUXMMcjs.HEADER_CONN_PARAMS);
|
|
6981
7045
|
let requestCtx;
|
|
6982
7046
|
let conn;
|
|
6983
7047
|
let removeRequestAbortListener;
|
|
@@ -7034,7 +7098,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7034
7098
|
requestCtx,
|
|
7035
7099
|
handlerRequest
|
|
7036
7100
|
);
|
|
7037
|
-
if (!
|
|
7101
|
+
if (!_chunkNG5CUXMMcjs.isResponseLike.call(void 0, response)) {
|
|
7038
7102
|
throw new Error(
|
|
7039
7103
|
"onRequest handler must return a Response"
|
|
7040
7104
|
);
|
|
@@ -7124,15 +7188,15 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7124
7188
|
}
|
|
7125
7189
|
);
|
|
7126
7190
|
})(),
|
|
7127
|
-
getWorkflowHistory:
|
|
7191
|
+
getWorkflowHistory: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
7128
7192
|
async (error, payload) => {
|
|
7129
7193
|
var _a2;
|
|
7130
7194
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
7131
7195
|
const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
|
|
7132
|
-
return history == null ? void 0 :
|
|
7196
|
+
return history == null ? void 0 : _chunkY4QLVCCScjs.toUint8Array.call(void 0, history);
|
|
7133
7197
|
}
|
|
7134
7198
|
) : void 0,
|
|
7135
|
-
replayWorkflow:
|
|
7199
|
+
replayWorkflow: _chunkSSF2XC33cjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
7136
7200
|
async (error, payload) => {
|
|
7137
7201
|
const { ctx, entryId } = unwrapTsfnPayload(
|
|
7138
7202
|
error,
|
|
@@ -7143,7 +7207,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7143
7207
|
return void 0;
|
|
7144
7208
|
}
|
|
7145
7209
|
const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
|
|
7146
|
-
return history == null ? void 0 :
|
|
7210
|
+
return history == null ? void 0 : _chunkY4QLVCCScjs.toUint8Array.call(void 0, history);
|
|
7147
7211
|
}
|
|
7148
7212
|
) : void 0,
|
|
7149
7213
|
actions: Object.fromEntries(
|
|
@@ -7153,6 +7217,11 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7153
7217
|
async (error, payload) => {
|
|
7154
7218
|
const { ctx, conn, args, scheduledFire, cancelToken } = unwrapTsfnPayload(error, payload);
|
|
7155
7219
|
const actorCtx = conn != null ? makeConnCtx(ctx, conn, void 0, cancelToken) : makeActorCtx(ctx, void 0, cancelToken);
|
|
7220
|
+
if (scheduledFire) {
|
|
7221
|
+
Object.defineProperty(actorCtx, "scheduledFire", {
|
|
7222
|
+
value: scheduledFire
|
|
7223
|
+
});
|
|
7224
|
+
}
|
|
7156
7225
|
const runAction = async () => {
|
|
7157
7226
|
try {
|
|
7158
7227
|
return encodeValue(
|
|
@@ -7265,57 +7334,62 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7265
7334
|
buildActorConfig(definition, registryConfig, runtime.kind)
|
|
7266
7335
|
);
|
|
7267
7336
|
}
|
|
7268
|
-
async function buildServeConfig(config,
|
|
7337
|
+
async function buildServeConfig(config, resolveNativeBinaries = true) {
|
|
7269
7338
|
var _a;
|
|
7270
7339
|
if (!config.endpoint) {
|
|
7271
7340
|
throw nativeEndpointNotConfiguredError();
|
|
7272
7341
|
}
|
|
7273
7342
|
const serveConfig = {
|
|
7274
|
-
version: config.
|
|
7343
|
+
version: config.node.version,
|
|
7275
7344
|
endpoint: config.endpoint,
|
|
7345
|
+
engineSpawn: config.engineSpawn,
|
|
7276
7346
|
token: config.token,
|
|
7277
7347
|
namespace: config.namespace,
|
|
7278
|
-
poolName: config.
|
|
7279
|
-
startServices:
|
|
7348
|
+
poolName: config.node.poolName,
|
|
7349
|
+
startServices: resolveNativeBinaries && config.startServices,
|
|
7280
7350
|
handleInspectorHttpInRuntime: true,
|
|
7281
7351
|
serverlessBasePath: config.serverless.basePath,
|
|
7282
|
-
serverlessPackageVersion:
|
|
7352
|
+
serverlessPackageVersion: _chunkY4QLVCCScjs.VERSION,
|
|
7283
7353
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
7284
7354
|
serverlessClientNamespace: config.publicNamespace,
|
|
7285
7355
|
serverlessClientToken: config.publicToken,
|
|
7286
7356
|
serverlessValidateEndpoint: config.validateServerlessEndpoint,
|
|
7287
7357
|
serverlessMaxStartPayloadBytes: config.serverless.maxStartPayloadBytes
|
|
7288
7358
|
};
|
|
7289
|
-
|
|
7290
|
-
const { getEnginePath } = await loadEngineCli();
|
|
7291
|
-
serveConfig.engineBinaryPath = getEnginePath();
|
|
7292
|
-
} catch (error) {
|
|
7293
|
-
logger2().warn({
|
|
7294
|
-
msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable \u2014 set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
|
|
7295
|
-
error: _chunkKDT56V3Ycjs.stringifyError.call(void 0, error)
|
|
7296
|
-
});
|
|
7297
|
-
}
|
|
7298
|
-
if (resolveServicesBinary && config.startServices) {
|
|
7359
|
+
if (resolveNativeBinaries) {
|
|
7299
7360
|
try {
|
|
7300
|
-
const {
|
|
7301
|
-
serveConfig.
|
|
7361
|
+
const { getEnginePath } = await loadEngineCli();
|
|
7362
|
+
serveConfig.engineBinaryPath = getEnginePath();
|
|
7302
7363
|
} catch (error) {
|
|
7303
7364
|
logger2().warn({
|
|
7304
|
-
msg: "could not resolve
|
|
7305
|
-
error:
|
|
7365
|
+
msg: "could not resolve a local engine binary; if a local engine must be spawned it will fail with engine.binary_unavailable \u2014 set RIVET_ENGINE_BINARY_PATH or install the @rivetkit/engine-cli platform package",
|
|
7366
|
+
error: _chunkY4QLVCCScjs.stringifyError.call(void 0, error)
|
|
7306
7367
|
});
|
|
7307
7368
|
}
|
|
7308
7369
|
}
|
|
7370
|
+
if (resolveNativeBinaries && config.startServices) {
|
|
7371
|
+
const servicesBinary = _chunkY4QLVCCScjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
|
|
7372
|
+
if (servicesBinary) {
|
|
7373
|
+
serveConfig.servicesBinaryPath = servicesBinary;
|
|
7374
|
+
} else {
|
|
7375
|
+
try {
|
|
7376
|
+
const { getServicesPath } = await loadServices();
|
|
7377
|
+
serveConfig.servicesBinaryPath = getServicesPath();
|
|
7378
|
+
} catch (error) {
|
|
7379
|
+
throw servicesBinaryUnavailable(error);
|
|
7380
|
+
}
|
|
7381
|
+
}
|
|
7382
|
+
}
|
|
7309
7383
|
serveConfig.engineHost = config.engineHost;
|
|
7310
7384
|
serveConfig.enginePort = config.enginePort;
|
|
7311
7385
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
7312
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
7386
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkY4QLVCCScjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
7313
7387
|
}
|
|
7314
7388
|
return serveConfig;
|
|
7315
7389
|
}
|
|
7316
7390
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
7317
7391
|
var _a;
|
|
7318
|
-
if (((_a = config.test) == null ? void 0 : _a.enabled) &&
|
|
7392
|
+
if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkY4QLVCCScjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
|
|
7319
7393
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
7320
7394
|
}
|
|
7321
7395
|
if (runtime.kind === "napi") {
|
|
@@ -7345,6 +7419,11 @@ async function buildConfiguredRegistry(config) {
|
|
|
7345
7419
|
|
|
7346
7420
|
// src/registry/index.ts
|
|
7347
7421
|
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
7422
|
+
var LOCAL_ENGINE_READY_TIMEOUT_MS = 6e4;
|
|
7423
|
+
var LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS = 4e3;
|
|
7424
|
+
function rejectServerless() {
|
|
7425
|
+
throw new Error("serverless is disabled in this version");
|
|
7426
|
+
}
|
|
7348
7427
|
function signalExitCode(signal) {
|
|
7349
7428
|
switch (signal) {
|
|
7350
7429
|
case "SIGINT":
|
|
@@ -7382,7 +7461,7 @@ function createApplicationFetch(application, runtime) {
|
|
|
7382
7461
|
signal: abortController.signal
|
|
7383
7462
|
})
|
|
7384
7463
|
);
|
|
7385
|
-
if (!
|
|
7464
|
+
if (!_chunkNG5CUXMMcjs.isResponseLike.call(void 0, response)) {
|
|
7386
7465
|
throw new TypeError(
|
|
7387
7466
|
"registry.listen() application fetch must return a Response"
|
|
7388
7467
|
);
|
|
@@ -7432,7 +7511,7 @@ var Registry = class {
|
|
|
7432
7511
|
var _a;
|
|
7433
7512
|
this.#config = config;
|
|
7434
7513
|
if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
|
|
7435
|
-
|
|
7514
|
+
_chunkY4QLVCCScjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
|
|
7436
7515
|
}
|
|
7437
7516
|
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
7438
7517
|
this.routes = {
|
|
@@ -7449,6 +7528,7 @@ var Registry = class {
|
|
|
7449
7528
|
*/
|
|
7450
7529
|
#ensureServerlessPoolConfigured(config) {
|
|
7451
7530
|
if (!config.configurePool) return void 0;
|
|
7531
|
+
rejectServerless();
|
|
7452
7532
|
if (!this.#configureServerlessPoolPromise) {
|
|
7453
7533
|
this.#configureServerlessPoolPromise = configureServerlessPool(
|
|
7454
7534
|
config
|
|
@@ -7473,6 +7553,7 @@ var Registry = class {
|
|
|
7473
7553
|
*/
|
|
7474
7554
|
async handler(request) {
|
|
7475
7555
|
var _a;
|
|
7556
|
+
rejectServerless();
|
|
7476
7557
|
const config = this.parseConfig();
|
|
7477
7558
|
this.#printWelcome(config, "serverless");
|
|
7478
7559
|
if (!this.#runtimeServerlessPromise) {
|
|
@@ -7634,6 +7715,7 @@ var Registry = class {
|
|
|
7634
7715
|
* ```
|
|
7635
7716
|
*/
|
|
7636
7717
|
serve() {
|
|
7718
|
+
rejectServerless();
|
|
7637
7719
|
return {
|
|
7638
7720
|
fetch: (request) => this.handler(request)
|
|
7639
7721
|
};
|
|
@@ -7658,10 +7740,13 @@ var Registry = class {
|
|
|
7658
7740
|
* ```
|
|
7659
7741
|
*/
|
|
7660
7742
|
async listen(opts = {}) {
|
|
7661
|
-
|
|
7662
|
-
|
|
7743
|
+
if (!opts.application) {
|
|
7744
|
+
rejectServerless();
|
|
7745
|
+
}
|
|
7746
|
+
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkY4QLVCCScjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
|
|
7747
|
+
const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkY4QLVCCScjs.getRivetkitPublicDir.call(void 0, )));
|
|
7663
7748
|
const config = this.parseConfig();
|
|
7664
|
-
if (opts.application &&
|
|
7749
|
+
if (opts.application && _chunkY4QLVCCScjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7665
7750
|
if (config.runtime === "wasm") {
|
|
7666
7751
|
throw new Error(
|
|
7667
7752
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
@@ -7737,7 +7822,7 @@ var Registry = class {
|
|
|
7737
7822
|
return jsonRouteResponse(503, {
|
|
7738
7823
|
status: "not_started",
|
|
7739
7824
|
runtime: "rivetkit",
|
|
7740
|
-
version:
|
|
7825
|
+
version: _chunkY4QLVCCScjs.VERSION
|
|
7741
7826
|
});
|
|
7742
7827
|
}
|
|
7743
7828
|
const { runtime, registry } = configured;
|
|
@@ -7745,7 +7830,7 @@ var Registry = class {
|
|
|
7745
7830
|
return jsonRouteResponse(501, {
|
|
7746
7831
|
status: "unsupported",
|
|
7747
7832
|
runtime: "rivetkit",
|
|
7748
|
-
version:
|
|
7833
|
+
version: _chunkY4QLVCCScjs.VERSION
|
|
7749
7834
|
});
|
|
7750
7835
|
}
|
|
7751
7836
|
const response = await runtime.registryHealth(registry);
|
|
@@ -7758,6 +7843,7 @@ var Registry = class {
|
|
|
7758
7843
|
* Returns serverless metadata suitable for mounting in a user-owned router.
|
|
7759
7844
|
*/
|
|
7760
7845
|
async #metadataRoute() {
|
|
7846
|
+
rejectServerless();
|
|
7761
7847
|
const configured = await this.#activeConfiguredRegistry();
|
|
7762
7848
|
if (!configured) {
|
|
7763
7849
|
return new Response("registry not started\n", {
|
|
@@ -7818,18 +7904,18 @@ var Registry = class {
|
|
|
7818
7904
|
#startEnvoy(config, printWelcome) {
|
|
7819
7905
|
var _a;
|
|
7820
7906
|
if (!this.#runtimeServePromise) {
|
|
7821
|
-
const configuredEnvoyVersion = (_a = this.#config.
|
|
7822
|
-
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" :
|
|
7907
|
+
const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
|
|
7908
|
+
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunkY4QLVCCScjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
|
|
7823
7909
|
logger2().info({
|
|
7824
7910
|
msg: "starting rivetkit envoy",
|
|
7825
|
-
rivetkitVersion:
|
|
7826
|
-
envoyVersion: config.
|
|
7911
|
+
rivetkitVersion: _chunkY4QLVCCScjs.VERSION,
|
|
7912
|
+
envoyVersion: config.node.version,
|
|
7827
7913
|
envoyVersionSource
|
|
7828
7914
|
});
|
|
7829
|
-
if (envoyVersionSource === "default" &&
|
|
7915
|
+
if (envoyVersionSource === "default" && _chunkY4QLVCCScjs.getNodeEnv.call(void 0, ) === "production") {
|
|
7830
7916
|
logger2().error({
|
|
7831
|
-
msg: "
|
|
7832
|
-
envoyVersion: config.
|
|
7917
|
+
msg: "node version defaulted because neither config.node.version nor RIVET_NODE_VERSION is set; actors will not drain automatically across deploys. See https://rivet.dev/docs/actors/versions",
|
|
7918
|
+
envoyVersion: config.node.version,
|
|
7833
7919
|
envoyVersionSource
|
|
7834
7920
|
});
|
|
7835
7921
|
}
|
|
@@ -7841,7 +7927,10 @@ var Registry = class {
|
|
|
7841
7927
|
}
|
|
7842
7928
|
);
|
|
7843
7929
|
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error) => {
|
|
7844
|
-
logger2().
|
|
7930
|
+
logger2().error({ error }, "runtime registry serve errored");
|
|
7931
|
+
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
7932
|
+
process.exit(1);
|
|
7933
|
+
}
|
|
7845
7934
|
});
|
|
7846
7935
|
this.#installSignalHandlers(config);
|
|
7847
7936
|
}
|
|
@@ -7871,7 +7960,7 @@ var Registry = class {
|
|
|
7871
7960
|
finishShutdownSignal(signal);
|
|
7872
7961
|
return;
|
|
7873
7962
|
}
|
|
7874
|
-
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
7963
|
+
this.#shutdownInFlight = this.#drain(config, true).catch((err) => {
|
|
7875
7964
|
logger2().warn({ err }, "shutdown error");
|
|
7876
7965
|
}).then(() => {
|
|
7877
7966
|
this.#removeSignalHandlers();
|
|
@@ -7907,12 +7996,18 @@ var Registry = class {
|
|
|
7907
7996
|
});
|
|
7908
7997
|
return this.#shutdownInFlight;
|
|
7909
7998
|
}
|
|
7910
|
-
async #drain(config) {
|
|
7999
|
+
async #drain(config, signalDriven = false) {
|
|
7911
8000
|
var _a;
|
|
7912
8001
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
7913
8002
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
7914
8003
|
const runtimes = /* @__PURE__ */ new Set();
|
|
7915
|
-
const
|
|
8004
|
+
const localDevSignal = signalDriven && _chunkY4QLVCCScjs.getNodeEnv.call(void 0, ) !== "production" && config.engineSpawn && config.endpoint !== void 0 && _chunkNG5CUXMMcjs.isLocalEngineEndpoint.call(void 0, config.endpoint);
|
|
8005
|
+
let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
|
|
8006
|
+
if (gracePeriodMs === void 0) {
|
|
8007
|
+
gracePeriodMs = localDevSignal ? LOCAL_DEV_SHUTDOWN_GRACE_PERIOD_MS : await _asyncNullishCoalesce(await this.#actorStopThresholdMs(
|
|
8008
|
+
_nullishCoalesce(modeAPromise, () => ( modeBPromise))
|
|
8009
|
+
), async () => ( 30 * 60 * 1e3));
|
|
8010
|
+
}
|
|
7916
8011
|
const drain = async () => {
|
|
7917
8012
|
const registries = [];
|
|
7918
8013
|
if (modeAPromise !== void 0) {
|
|
@@ -8017,12 +8112,16 @@ var Registry = class {
|
|
|
8017
8112
|
);
|
|
8018
8113
|
}
|
|
8019
8114
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8115
|
+
try {
|
|
8116
|
+
if (_chunkY4QLVCCScjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8117
|
+
return Promise.reject(
|
|
8118
|
+
new Error(
|
|
8119
|
+
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
8120
|
+
)
|
|
8121
|
+
);
|
|
8122
|
+
}
|
|
8123
|
+
} catch (error) {
|
|
8124
|
+
return Promise.reject(error);
|
|
8026
8125
|
}
|
|
8027
8126
|
const config = this.parseConfig();
|
|
8028
8127
|
if (config.runtime === "wasm") {
|
|
@@ -8038,16 +8137,17 @@ var Registry = class {
|
|
|
8038
8137
|
if (!configuredRegistryPromise || !serveLifecyclePromise) {
|
|
8039
8138
|
throw new Error("registry envoy startup did not initialize");
|
|
8040
8139
|
}
|
|
8140
|
+
const readyTimeoutMs = config.engineSpawn && config.endpoint !== void 0 && _chunkNG5CUXMMcjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? LOCAL_ENGINE_READY_TIMEOUT_MS : REGISTRY_READY_TIMEOUT_MS;
|
|
8041
8141
|
let timeout;
|
|
8042
8142
|
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
8043
8143
|
var _a;
|
|
8044
8144
|
timeout = setTimeout(
|
|
8045
8145
|
() => reject(
|
|
8046
8146
|
new Error(
|
|
8047
|
-
`RivetKit registry did not register with the Engine within ${
|
|
8147
|
+
`RivetKit registry did not register with the Engine within ${readyTimeoutMs}ms`
|
|
8048
8148
|
)
|
|
8049
8149
|
),
|
|
8050
|
-
|
|
8150
|
+
readyTimeoutMs
|
|
8051
8151
|
);
|
|
8052
8152
|
(_a = timeout.unref) == null ? void 0 : _a.call(timeout);
|
|
8053
8153
|
});
|
|
@@ -8087,8 +8187,8 @@ var Registry = class {
|
|
|
8087
8187
|
* ```
|
|
8088
8188
|
*/
|
|
8089
8189
|
start() {
|
|
8090
|
-
if (
|
|
8091
|
-
const publicDir = _nullishCoalesce(
|
|
8190
|
+
if (_chunkY4QLVCCScjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8191
|
+
const publicDir = _nullishCoalesce(_chunkY4QLVCCScjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
|
|
8092
8192
|
this.listen({ publicDir }).catch((error) => {
|
|
8093
8193
|
logger2().error({ error }, "auto-listen failed; exiting");
|
|
8094
8194
|
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
@@ -8109,13 +8209,13 @@ var Registry = class {
|
|
|
8109
8209
|
};
|
|
8110
8210
|
console.log();
|
|
8111
8211
|
console.log(
|
|
8112
|
-
` RivetKit ${
|
|
8212
|
+
` RivetKit ${_chunkY4QLVCCScjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
8113
8213
|
);
|
|
8114
8214
|
if (config.namespace !== "default") {
|
|
8115
8215
|
logLine("Namespace", config.namespace);
|
|
8116
8216
|
}
|
|
8117
8217
|
if (config.endpoint) {
|
|
8118
|
-
const endpointType = config.startEngine ||
|
|
8218
|
+
const endpointType = config.startEngine || _chunkNG5CUXMMcjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
|
|
8119
8219
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
8120
8220
|
}
|
|
8121
8221
|
if (kind === "serverless" && config.publicEndpoint) {
|
|
@@ -8185,5 +8285,5 @@ function setup(input) {
|
|
|
8185
8285
|
|
|
8186
8286
|
|
|
8187
8287
|
|
|
8188
|
-
exports.ALLOWED_PUBLIC_HEADERS =
|
|
8288
|
+
exports.ALLOWED_PUBLIC_HEADERS = _chunkNG5CUXMMcjs.ALLOWED_PUBLIC_HEADERS; exports.ActorDefinition = ActorDefinition; exports.ActorError = _chunkMGI2VVF6cjs.RivetError; exports.ActorsSchema = ActorsSchema; exports.DocConfigurePoolSchema = DocConfigurePoolSchema; exports.DocEnvoyConfigSchema = DocEnvoyConfigSchema; exports.DocRegistryConfigSchema = DocRegistryConfigSchema; exports.DocServerlessConfigSchema = DocServerlessConfigSchema; exports.DocSqliteConfigSchema = DocSqliteConfigSchema; exports.InlineWebSocketAdapter = InlineWebSocketAdapter; exports.Registry = Registry; exports.RegistryConfigSchema = RegistryConfigSchema; exports.RivetError = _chunkMGI2VVF6cjs.RivetError; exports.RuntimeKindSchema = RuntimeKindSchema; exports.SqliteBackendSchema = SqliteBackendSchema; exports.SqliteConfigSchema = SqliteConfigSchema; exports.TestConfigSchema = TestConfigSchema; exports.UserError = _chunkMGI2VVF6cjs.UserError; exports.WasmRuntimeConfigSchema = WasmRuntimeConfigSchema; exports.actor = actor; exports.buildActorNames = buildActorNames; exports.createClientWithDriver = _chunkNG5CUXMMcjs.createClientWithDriver; exports.defineRunHandler = _chunkSSF2XC33cjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkY4QLVCCScjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkY4QLVCCScjs.toUint8Array;
|
|
8189
8289
|
//# sourceMappingURL=mod.cjs.map
|