rivetkit 2.3.29 → 3.0.0-preview.1
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 +58 -9
- package/dist/browser/client.js +193 -20
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -2
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-WHAUEDUT.cjs → chunk-3E2BPHQO.cjs} +10 -10
- package/dist/tsup/{chunk-WHAUEDUT.cjs.map → chunk-3E2BPHQO.cjs.map} +1 -1
- package/dist/tsup/{chunk-K7QBHEVI.js → chunk-3MMTF3QA.js} +185 -25
- package/dist/tsup/chunk-3MMTF3QA.js.map +1 -0
- package/dist/tsup/{chunk-WHA3XM3R.js → chunk-5OCN7VHH.js} +10 -11
- package/dist/tsup/chunk-5OCN7VHH.js.map +1 -0
- package/dist/tsup/{chunk-CRBPB6QI.cjs → chunk-6DDQSAAT.cjs} +7 -7
- package/dist/tsup/{chunk-CRBPB6QI.cjs.map → chunk-6DDQSAAT.cjs.map} +1 -1
- package/dist/tsup/{chunk-JI6GZ2C2.js → chunk-A2CF6PFH.js} +18 -1
- package/dist/tsup/chunk-A2CF6PFH.js.map +1 -0
- package/dist/tsup/{chunk-WSSI5L6L.cjs → chunk-CTQKKUZC.cjs} +326 -166
- package/dist/tsup/chunk-CTQKKUZC.cjs.map +1 -0
- package/dist/tsup/{chunk-IXJCAFAQ.js → chunk-DCDCHB5J.js} +2 -2
- package/dist/tsup/{chunk-SNFXCNXD.js → chunk-DQ6K3VVV.js} +3 -3
- package/dist/tsup/{chunk-RY6Z4RA5.js → chunk-H6W37YLT.js} +2 -2
- package/dist/tsup/{chunk-Q6GKUC22.cjs → chunk-HW2D5OFJ.cjs} +3 -3
- package/dist/tsup/{chunk-Q6GKUC22.cjs.map → chunk-HW2D5OFJ.cjs.map} +1 -1
- package/dist/tsup/{chunk-DTGPF6XY.cjs → chunk-IBEFA6CX.cjs} +10 -11
- package/dist/tsup/chunk-IBEFA6CX.cjs.map +1 -0
- package/dist/tsup/{chunk-56QW6V7F.cjs → chunk-JLBPBEWC.cjs} +3 -3
- package/dist/tsup/{chunk-56QW6V7F.cjs.map → chunk-JLBPBEWC.cjs.map} +1 -1
- package/dist/tsup/{chunk-JMUNIWKG.js → chunk-KQ2WQDYT.js} +2 -2
- package/dist/tsup/{chunk-MYWZCDML.cjs → chunk-RTWH3AX3.cjs} +19 -2
- package/dist/tsup/chunk-RTWH3AX3.cjs.map +1 -0
- package/dist/tsup/{chunk-U3KY2OGG.js → chunk-SJPPKBT3.js} +2 -2
- package/dist/tsup/{chunk-7TRYBX2R.js → chunk-TBJ4I3R3.js} +4 -4
- package/dist/tsup/{chunk-NK4D6G45.cjs → chunk-VCVV726P.cjs} +4 -4
- package/dist/tsup/{chunk-NK4D6G45.cjs.map → chunk-VCVV726P.cjs.map} +1 -1
- package/dist/tsup/{chunk-RDBXO2ND.cjs → chunk-XUO6G4H6.cjs} +3 -3
- package/dist/tsup/{chunk-RDBXO2ND.cjs.map → chunk-XUO6G4H6.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-osdJqQwX.d.cts → config-8NgsxIcT.d.cts} +43 -12
- package/dist/tsup/{config-ey2I2zz5.d.cts → config-B2wlj9wx.d.cts} +7 -1
- package/dist/tsup/{config-ey2I2zz5.d.ts → config-B2wlj9wx.d.ts} +7 -1
- package/dist/tsup/{config-Cv6pjCt-.d.ts → config-DJ3KW-fe.d.ts} +43 -12
- package/dist/tsup/{context-CoVbKBuk.d.ts → context-BL8kUGjq.d.ts} +2 -2
- package/dist/tsup/{context-DpjrM7n7.d.cts → context-_RoE_YHL.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 +254 -166
- 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 +168 -80
- 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.d.cts +4 -4
- package/dist/tsup/workflow/mod.d.ts +4 -4
- package/dist/tsup/workflow/mod.js +5 -5
- package/package.json +9 -10
- package/src/actor/keys.ts +86 -0
- package/src/client/actor-conn.ts +92 -6
- package/src/client/actor-handle.ts +21 -3
- package/src/client/client.ts +6 -0
- package/src/client/config.ts +12 -1
- package/src/client/lifecycle-errors.ts +16 -1
- package/src/client/retry-budget.ts +78 -0
- package/src/client/utils.ts +13 -2
- package/src/common/database/config.ts +7 -1
- 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 +28 -31
- package/src/registry/index.ts +51 -19
- package/src/registry/napi-runtime.ts +3 -2
- package/src/registry/native.ts +126 -34
- package/src/registry/runtime.ts +27 -10
- package/src/registry/wasm-runtime.ts +6 -3
- package/src/utils/env-vars.ts +15 -10
- package/dist/tsup/chunk-DTGPF6XY.cjs.map +0 -1
- package/dist/tsup/chunk-JI6GZ2C2.js.map +0 -1
- package/dist/tsup/chunk-K7QBHEVI.js.map +0 -1
- package/dist/tsup/chunk-MYWZCDML.cjs.map +0 -1
- package/dist/tsup/chunk-WHA3XM3R.js.map +0 -1
- package/dist/tsup/chunk-WSSI5L6L.cjs.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-IXJCAFAQ.js.map → chunk-DCDCHB5J.js.map} +0 -0
- /package/dist/tsup/{chunk-SNFXCNXD.js.map → chunk-DQ6K3VVV.js.map} +0 -0
- /package/dist/tsup/{chunk-RY6Z4RA5.js.map → chunk-H6W37YLT.js.map} +0 -0
- /package/dist/tsup/{chunk-JMUNIWKG.js.map → chunk-KQ2WQDYT.js.map} +0 -0
- /package/dist/tsup/{chunk-U3KY2OGG.js.map → chunk-SJPPKBT3.js.map} +0 -0
- /package/dist/tsup/{chunk-7TRYBX2R.js.map → chunk-TBJ4I3R3.js.map} +0 -0
package/dist/tsup/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
3
|
+
var _chunkVCVV726Pcjs = require('./chunk-VCVV726P.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -35,17 +35,17 @@ var _chunkHDVZ6YZGcjs = require('./chunk-HDVZ6YZG.cjs');
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _chunkCTQKKUZCcjs = require('./chunk-CTQKKUZC.cjs');
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
var
|
|
43
|
-
require('./chunk-
|
|
42
|
+
var _chunkRTWH3AX3cjs = require('./chunk-RTWH3AX3.cjs');
|
|
43
|
+
require('./chunk-HW2D5OFJ.cjs');
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _chunkJLBPBEWCcjs = require('./chunk-JLBPBEWC.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 _chunkIBEFA6CXcjs = require('./chunk-IBEFA6CX.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 _chunkIBEFA6CXcjs.getLogger.call(void 0, "actor-runtime");
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
// src/actor/definition.ts
|
|
@@ -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 _chunkIBEFA6CXcjs.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 _chunkIBEFA6CXcjs.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 = _chunkCTQKKUZCcjs.convertRegistryConfigToClientConfig.call(void 0, config);
|
|
442
|
+
const dcsRes = await _chunkCTQKKUZCcjs.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 _chunkCTQKKUZCcjs.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: _chunkIBEFA6CXcjs.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: _chunkIBEFA6CXcjs.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(_chunkIBEFA6CXcjs.getRivetPool.call(void 0, ), () => ( "default"))),
|
|
501
|
+
version: _v4.z.number().default(() => _nullishCoalesce(_chunkIBEFA6CXcjs.getRivetEnvoyVersion.call(void 0, ), () => ( 1))),
|
|
501
502
|
// Deprecated.
|
|
502
|
-
totalSlots: _v4.z.number().default(() => _nullishCoalesce(
|
|
503
|
-
|
|
503
|
+
totalSlots: _v4.z.number().default(() => _nullishCoalesce(_chunkIBEFA6CXcjs.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, () => ( _chunkIBEFA6CXcjs.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, () => ( _chunkIBEFA6CXcjs.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, () => ( _chunkIBEFA6CXcjs.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: _chunkIBEFA6CXcjs.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, () => ( _chunkIBEFA6CXcjs.getRivetEngine.call(void 0, ))), () => ( _chunkIBEFA6CXcjs.getRivetEndpoint.call(void 0, )))),
|
|
659
|
+
token: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkIBEFA6CXcjs.getRivetToken.call(void 0, )))),
|
|
660
|
+
namespace: _zod.z.string().optional().transform((val) => _nullishCoalesce(val, () => ( _chunkIBEFA6CXcjs.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(() => _chunkIBEFA6CXcjs.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(_chunkIBEFA6CXcjs.getRivetRunEngineHost.call(void 0, ), () => ( _chunkCTQKKUZCcjs.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(_chunkIBEFA6CXcjs.getRivetRunEnginePort.call(void 0, ), () => ( _chunkCTQKKUZCcjs.ENGINE_PORT))),
|
|
712
713
|
/** @experimental */
|
|
713
|
-
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(
|
|
714
|
+
engineVersion: _zod.z.string().optional().default(() => _nullishCoalesce(_chunkIBEFA6CXcjs.getRivetRunEngineVersion.call(void 0, ), () => ( _chunkIBEFA6CXcjs.VERSION))),
|
|
714
715
|
/**
|
|
715
716
|
* Starts the first-party Services actor host when RivetKit manages
|
|
716
|
-
* a local engine.
|
|
717
|
-
*
|
|
717
|
+
* a local engine. Disabled by default. Set RIVET_RUN_SERVICES=1
|
|
718
|
+
* or startServices: true to enable 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,11 @@ 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
|
+
* one second by default so a file watcher can restart promptly.
|
|
752
755
|
*
|
|
753
|
-
*
|
|
756
|
+
* Set a longer period when a complete graceful node drain is required.
|
|
754
757
|
*/
|
|
755
758
|
gracePeriodMs: _zod.z.number().int().min(1e3).optional(),
|
|
756
759
|
/**
|
|
@@ -764,7 +767,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
764
767
|
}))
|
|
765
768
|
}).transform((config, ctx) => {
|
|
766
769
|
var _a, _b, _c;
|
|
767
|
-
const isDevEnv =
|
|
770
|
+
const isDevEnv = _chunkIBEFA6CXcjs.isDev.call(void 0, );
|
|
768
771
|
const sqliteBackend = _nullishCoalesce(((_a = config.sqlite) == null ? void 0 : _a.backend), () => ( ((_b = config.test) == null ? void 0 : _b.sqliteBackend)));
|
|
769
772
|
if (config.runtime === "wasm" && sqliteBackend === "local") {
|
|
770
773
|
ctx.addIssue({
|
|
@@ -774,7 +777,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
774
777
|
});
|
|
775
778
|
}
|
|
776
779
|
const sqlite = config.runtime === "wasm" && config.sqlite === void 0 ? { backend: "remote" } : config.sqlite;
|
|
777
|
-
const parsedEndpoint = config.endpoint ?
|
|
780
|
+
const parsedEndpoint = config.endpoint ? _chunkCTQKKUZCcjs.tryParseEndpoint.call(void 0, ctx, {
|
|
778
781
|
endpoint: config.endpoint,
|
|
779
782
|
path: ["endpoint"],
|
|
780
783
|
namespace: config.namespace,
|
|
@@ -786,24 +789,25 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
786
789
|
message: "cannot specify both startEngine and endpoint"
|
|
787
790
|
});
|
|
788
791
|
}
|
|
789
|
-
if (config.configurePool
|
|
792
|
+
if (config.configurePool) {
|
|
790
793
|
ctx.addIssue({
|
|
791
794
|
code: "custom",
|
|
792
|
-
message: "
|
|
795
|
+
message: "serverless is disabled in this version",
|
|
796
|
+
path: ["configurePool"]
|
|
793
797
|
});
|
|
794
798
|
}
|
|
795
|
-
const localEngineEndpoint =
|
|
799
|
+
const localEngineEndpoint = _chunkCTQKKUZCcjs.buildEngineEndpoint.call(void 0,
|
|
796
800
|
config.engineHost,
|
|
797
801
|
config.enginePort
|
|
798
802
|
);
|
|
799
803
|
const endpoint = config.startEngine ? localEngineEndpoint : _nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.endpoint), () => ( (isDevEnv ? localEngineEndpoint : void 0)));
|
|
800
|
-
const startServices = _nullishCoalesce(
|
|
804
|
+
const startServices = _nullishCoalesce(config.startServices, () => ( _chunkIBEFA6CXcjs.getRivetRunServices.call(void 0, )));
|
|
801
805
|
const validateServerlessEndpoint = Boolean(
|
|
802
806
|
config.startEngine || parsedEndpoint
|
|
803
807
|
);
|
|
804
808
|
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 ?
|
|
809
|
+
const token = _nullishCoalesce(_nullishCoalesce((parsedEndpoint == null ? void 0 : parsedEndpoint.token), () => ( config.token)), () => ( (endpoint && _chunkCTQKKUZCcjs.isLocalEngineEndpoint.call(void 0, endpoint) ? "default" : void 0)));
|
|
810
|
+
const parsedPublicEndpoint = config.serverless.publicEndpoint ? _chunkCTQKKUZCcjs.tryParseEndpoint.call(void 0, ctx, {
|
|
807
811
|
endpoint: config.serverless.publicEndpoint,
|
|
808
812
|
path: ["serverless", "publicEndpoint"]
|
|
809
813
|
}) : void 0;
|
|
@@ -821,6 +825,7 @@ var RegistryConfigSchema = _zod.z.object({
|
|
|
821
825
|
...config,
|
|
822
826
|
sqlite,
|
|
823
827
|
endpoint,
|
|
828
|
+
engineSpawn: !parsedEndpoint && Boolean(endpoint),
|
|
824
829
|
startServices,
|
|
825
830
|
namespace,
|
|
826
831
|
token,
|
|
@@ -850,8 +855,8 @@ function buildActorNames(config) {
|
|
|
850
855
|
);
|
|
851
856
|
}
|
|
852
857
|
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
|
|
858
|
+
name: _zod.z.string().optional().describe("Name of the node pool."),
|
|
859
|
+
url: _zod.z.string().describe("URL of the serverless platform to configure nodes."),
|
|
855
860
|
headers: _zod.z.record(_zod.z.string(), _zod.z.string()).optional().describe(
|
|
856
861
|
"Headers to include in requests to the serverless platform."
|
|
857
862
|
),
|
|
@@ -866,7 +871,7 @@ var DocConfigurePoolSchema = _zod.z.object({
|
|
|
866
871
|
"Interval in milliseconds between metadata polls from the engine. Defaults to 10000 milliseconds (10 seconds)."
|
|
867
872
|
),
|
|
868
873
|
drainOnVersionUpgrade: _zod.z.boolean().optional().describe(
|
|
869
|
-
"Drain
|
|
874
|
+
"Drain nodes when a new version is deployed. Defaults to true."
|
|
870
875
|
)
|
|
871
876
|
}).optional();
|
|
872
877
|
var DocServerlessConfigSchema = _zod.z.object({
|
|
@@ -885,10 +890,10 @@ var DocServerlessConfigSchema = _zod.z.object({
|
|
|
885
890
|
}).describe("Configuration for serverless deployment mode.");
|
|
886
891
|
var DocEnvoyConfigSchema = _zod.z.object({
|
|
887
892
|
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
|
|
893
|
+
poolName: _zod.z.string().optional().describe("Name of this node pool. Default: 'default'"),
|
|
894
|
+
nodeKey: _zod.z.string().optional().describe("Deprecated. Authentication key for the node."),
|
|
895
|
+
version: _zod.z.number().optional().describe("Version number of this node. Default: 1")
|
|
896
|
+
}).describe("Configuration for node mode.");
|
|
892
897
|
var DocSqliteConfigSchema = _zod.z.object({
|
|
893
898
|
backend: SqliteBackendSchema.optional().describe(
|
|
894
899
|
"SQLite backend to use. Native defaults to local. Wasm defaults to remote and cannot use local."
|
|
@@ -907,7 +912,7 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
907
912
|
noWelcome: _zod.z.boolean().optional().describe("Disable the welcome message on startup. Default: false"),
|
|
908
913
|
sqlite: DocSqliteConfigSchema,
|
|
909
914
|
logging: _zod.z.object({
|
|
910
|
-
level:
|
|
915
|
+
level: _chunkIBEFA6CXcjs.LogLevelSchema.optional().describe(
|
|
911
916
|
"Log level for RivetKit. Default: 'warn'"
|
|
912
917
|
)
|
|
913
918
|
}).optional().describe("Logging configuration."),
|
|
@@ -936,13 +941,13 @@ var DocRegistryConfigSchema = _zod.z.object({
|
|
|
936
941
|
"Version of the local engine package to use. Defaults to the current RivetKit version."
|
|
937
942
|
),
|
|
938
943
|
startServices: _zod.z.boolean().optional().describe(
|
|
939
|
-
"Starts Services when RivetKit manages a local Engine.
|
|
944
|
+
"Starts Services when RivetKit manages a local Engine. Disabled by default. Set RIVET_RUN_SERVICES=1 or startServices: true to enable."
|
|
940
945
|
),
|
|
941
946
|
configurePool: DocConfigurePoolSchema.describe(
|
|
942
|
-
"Automatically configure serverless
|
|
947
|
+
"Automatically configure serverless nodes in the engine."
|
|
943
948
|
),
|
|
944
949
|
serverless: DocServerlessConfigSchema.optional(),
|
|
945
|
-
|
|
950
|
+
node: DocEnvoyConfigSchema.optional()
|
|
946
951
|
}).describe("RivetKit registry configuration.");
|
|
947
952
|
|
|
948
953
|
// src/registry/native.ts
|
|
@@ -1105,12 +1110,12 @@ var NativeCloseGate = class {
|
|
|
1105
1110
|
if (this.#active > 0) {
|
|
1106
1111
|
await new Promise((resolve) => this.#waiters.push(resolve));
|
|
1107
1112
|
}
|
|
1108
|
-
await callback();
|
|
1113
|
+
await (callback == null ? void 0 : callback());
|
|
1109
1114
|
}
|
|
1110
1115
|
};
|
|
1111
1116
|
function wrapJsNativeDatabase(database) {
|
|
1112
1117
|
const gate = new NativeCloseGate();
|
|
1113
|
-
let
|
|
1118
|
+
let terminalPromise;
|
|
1114
1119
|
let lastInsertRowId = null;
|
|
1115
1120
|
const executeNative = async (sql, params) => {
|
|
1116
1121
|
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
@@ -1245,8 +1250,12 @@ function wrapJsNativeDatabase(database) {
|
|
|
1245
1250
|
return normalizeNativeMetrics((_a = database.metrics) == null ? void 0 : _a.call(database));
|
|
1246
1251
|
},
|
|
1247
1252
|
async close() {
|
|
1248
|
-
|
|
1249
|
-
await
|
|
1253
|
+
terminalPromise ??= gate.close(() => database.close());
|
|
1254
|
+
await terminalPromise;
|
|
1255
|
+
},
|
|
1256
|
+
async detachForShutdown() {
|
|
1257
|
+
terminalPromise ??= gate.close();
|
|
1258
|
+
await terminalPromise;
|
|
1250
1259
|
}
|
|
1251
1260
|
};
|
|
1252
1261
|
}
|
|
@@ -1392,6 +1401,12 @@ function getNodePath() {
|
|
|
1392
1401
|
function normalizeRuntimeSqlExecuteResult(result) {
|
|
1393
1402
|
return result;
|
|
1394
1403
|
}
|
|
1404
|
+
function servicesBinaryUnavailable(cause) {
|
|
1405
|
+
return new Error(
|
|
1406
|
+
"services.binary_unavailable: Install @rivet-dev/services yourself to run local Services, or set RIVET_SERVICES_BINARY to its executable path.",
|
|
1407
|
+
{ cause }
|
|
1408
|
+
);
|
|
1409
|
+
}
|
|
1395
1410
|
|
|
1396
1411
|
// src/registry/napi-runtime.ts
|
|
1397
1412
|
function asNativeRegistry(handle) {
|
|
@@ -1537,7 +1552,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1537
1552
|
if (!(active == null ? void 0 : active.sameActorInstance(ownerCtx))) {
|
|
1538
1553
|
return ownerCtx;
|
|
1539
1554
|
}
|
|
1540
|
-
const applicationSpan =
|
|
1555
|
+
const applicationSpan = _chunkCTQKKUZCcjs.readActiveTraceHeaders.call(void 0, );
|
|
1541
1556
|
if (!applicationSpan) {
|
|
1542
1557
|
return active;
|
|
1543
1558
|
}
|
|
@@ -1664,7 +1679,8 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1664
1679
|
asNativeCancellationToken(token).cancel();
|
|
1665
1680
|
}
|
|
1666
1681
|
onCancellationTokenCancelled(token, callback) {
|
|
1667
|
-
asNativeCancellationToken(token).onCancelled(callback);
|
|
1682
|
+
const listener = asNativeCancellationToken(token).onCancelled(callback);
|
|
1683
|
+
return () => listener.release();
|
|
1668
1684
|
}
|
|
1669
1685
|
actorState(ctx) {
|
|
1670
1686
|
return asNativeActorContext(ctx).state();
|
|
@@ -1740,7 +1756,7 @@ var NapiCoreRuntime = (_class = class {
|
|
|
1740
1756
|
const span = (_a = nativeCtx.invocationTraceContext()) == null ? void 0 : _a.span;
|
|
1741
1757
|
return this.#invocationContext.run(
|
|
1742
1758
|
nativeCtx,
|
|
1743
|
-
() =>
|
|
1759
|
+
() => _chunkCTQKKUZCcjs.runWithActorInvocationSpan.call(void 0, span, run)
|
|
1744
1760
|
);
|
|
1745
1761
|
}
|
|
1746
1762
|
actorInvocationTraceContext(ctx) {
|
|
@@ -2115,8 +2131,8 @@ function runtimeBytesToArrayBuffer(value) {
|
|
|
2115
2131
|
function buildNativeHttpRequest(init) {
|
|
2116
2132
|
var _a;
|
|
2117
2133
|
const headers = new Headers(init.headers);
|
|
2118
|
-
const originalUrl = headers.get(
|
|
2119
|
-
headers.delete(
|
|
2134
|
+
const originalUrl = headers.get(_chunkCTQKKUZCcjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2135
|
+
headers.delete(_chunkCTQKKUZCcjs.HEADER_ORIGINAL_REQUEST_URL);
|
|
2120
2136
|
const url = _nullishCoalesce(originalUrl, () => ( (init.uri.startsWith("http") ? init.uri : new URL(init.uri, "http://127.0.0.1").toString())));
|
|
2121
2137
|
const method2 = init.method.toUpperCase();
|
|
2122
2138
|
const bodyForbidden = method2 === "GET" || method2 === "HEAD";
|
|
@@ -2195,7 +2211,7 @@ async function pumpResponseBody(reader, stream) {
|
|
|
2195
2211
|
}
|
|
2196
2212
|
} catch (error) {
|
|
2197
2213
|
try {
|
|
2198
|
-
await stream.error(
|
|
2214
|
+
await stream.error(_chunkIBEFA6CXcjs.stringifyError.call(void 0, error));
|
|
2199
2215
|
} catch (streamError) {
|
|
2200
2216
|
logger2().debug({
|
|
2201
2217
|
msg: "failed to report native http response stream error",
|
|
@@ -2703,9 +2719,10 @@ var WasmCoreRuntime = (_class2 = class {
|
|
|
2703
2719
|
callWasmSync(() => asWasmCancellationToken(token).cancel());
|
|
2704
2720
|
}
|
|
2705
2721
|
onCancellationTokenCancelled(token, callback) {
|
|
2706
|
-
callWasmSync(
|
|
2722
|
+
const listener = callWasmSync(
|
|
2707
2723
|
() => asWasmCancellationToken(token).onCancelled(callback)
|
|
2708
2724
|
);
|
|
2725
|
+
return () => callWasmSync(() => listener.release());
|
|
2709
2726
|
}
|
|
2710
2727
|
actorState(ctx) {
|
|
2711
2728
|
return toBytes(
|
|
@@ -3433,7 +3450,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3433
3450
|
nativeError = error;
|
|
3434
3451
|
logger2().warn({
|
|
3435
3452
|
msg: "native runtime failed to load; falling back to wasm",
|
|
3436
|
-
error:
|
|
3453
|
+
error: _chunkIBEFA6CXcjs.stringifyError.call(void 0, error)
|
|
3437
3454
|
});
|
|
3438
3455
|
}
|
|
3439
3456
|
try {
|
|
@@ -3442,7 +3459,7 @@ async function loadAutoRuntime(config, loaders = defaultRuntimeLoaders) {
|
|
|
3442
3459
|
throw new (0, _chunkMGI2VVF6cjs.RivetError)(
|
|
3443
3460
|
"config",
|
|
3444
3461
|
"runtime_unavailable",
|
|
3445
|
-
`RivetKit could not load a core runtime. Native runtime: ${
|
|
3462
|
+
`RivetKit could not load a core runtime. Native runtime: ${_chunkIBEFA6CXcjs.stringifyError.call(void 0, nativeError)} Wasm runtime: ${_chunkIBEFA6CXcjs.stringifyError.call(void 0, wasmError)}`,
|
|
3446
3463
|
{
|
|
3447
3464
|
public: true,
|
|
3448
3465
|
statusCode: 500
|
|
@@ -3498,9 +3515,10 @@ function normalizeRuntimeConfig(config, runtime) {
|
|
|
3498
3515
|
return normalizeRuntimeConfigForKind(config, loadedRuntimeKind(runtime));
|
|
3499
3516
|
}
|
|
3500
3517
|
function getNativeRuntimeState(runtime, ctx) {
|
|
3501
|
-
const runtimeState =
|
|
3502
|
-
|
|
3503
|
-
|
|
3518
|
+
const runtimeState = readNativeRuntimeStateBag(runtime, ctx);
|
|
3519
|
+
if (runtimeState.cleared) {
|
|
3520
|
+
throw _chunkMGI2VVF6cjs.actorStopping.call(void 0, callNativeSync(() => runtime.actorId(ctx)));
|
|
3521
|
+
}
|
|
3504
3522
|
if (!runtimeState.destroyGate) {
|
|
3505
3523
|
runtimeState.destroyGate = {};
|
|
3506
3524
|
}
|
|
@@ -3513,6 +3531,14 @@ function getNativeRuntimeState(runtime, ctx) {
|
|
|
3513
3531
|
}
|
|
3514
3532
|
return runtimeState;
|
|
3515
3533
|
}
|
|
3534
|
+
function readNativeRuntimeStateBag(runtime, ctx) {
|
|
3535
|
+
return callNativeSync(
|
|
3536
|
+
() => runtime.actorRuntimeState(ctx)
|
|
3537
|
+
);
|
|
3538
|
+
}
|
|
3539
|
+
function isNativeRuntimeStateCleared(runtime, ctx) {
|
|
3540
|
+
return readNativeRuntimeStateBag(runtime, ctx).cleared === true;
|
|
3541
|
+
}
|
|
3516
3542
|
function getNativePersistState(runtime, ctx) {
|
|
3517
3543
|
const persistState = getNativeRuntimeState(runtime, ctx).persistState;
|
|
3518
3544
|
if (!persistState) {
|
|
@@ -3623,29 +3649,43 @@ function resolveNativeDestroy(runtime, ctx) {
|
|
|
3623
3649
|
gate.destroyCompletion = void 0;
|
|
3624
3650
|
}
|
|
3625
3651
|
function clearNativeRuntimeState(runtime, ctx) {
|
|
3652
|
+
var _a;
|
|
3653
|
+
const pendingSaveHandle = (_a = readNativeRuntimeStateBag(runtime, ctx).persistState) == null ? void 0 : _a.pendingSaveHandle;
|
|
3654
|
+
if (pendingSaveHandle !== void 0) {
|
|
3655
|
+
clearImmediate(pendingSaveHandle);
|
|
3656
|
+
}
|
|
3626
3657
|
callNativeSync(() => runtime.actorClearRuntimeState(ctx));
|
|
3658
|
+
readNativeRuntimeStateBag(runtime, ctx).cleared = true;
|
|
3627
3659
|
}
|
|
3628
3660
|
async function cleanupNativeSleepRuntimeState(runtime, ctx, afterTrackedWorkDrained) {
|
|
3629
3661
|
const drained = await runtime.actorWaitForTrackedShutdownWork(ctx);
|
|
3630
3662
|
if (!drained) {
|
|
3631
|
-
await
|
|
3632
|
-
await closeNativeSqlDatabase(runtime, ctx);
|
|
3663
|
+
await detachNativeDatabaseForShutdown(runtime, ctx);
|
|
3633
3664
|
void runtime.actorWaitForTrackedShutdownWorkUnbounded(ctx).then(async () => {
|
|
3634
3665
|
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
3635
3666
|
clearNativeRuntimeState(runtime, ctx);
|
|
3636
3667
|
}).catch((error) => {
|
|
3637
3668
|
logger2().warn({
|
|
3638
3669
|
msg: "deferred native sleep cleanup failed",
|
|
3639
|
-
error:
|
|
3670
|
+
error: _chunkIBEFA6CXcjs.stringifyError.call(void 0, error)
|
|
3640
3671
|
});
|
|
3641
3672
|
});
|
|
3642
3673
|
return;
|
|
3643
3674
|
}
|
|
3644
3675
|
await (afterTrackedWorkDrained == null ? void 0 : afterTrackedWorkDrained());
|
|
3645
|
-
await
|
|
3646
|
-
await closeNativeSqlDatabase(runtime, ctx);
|
|
3676
|
+
await detachNativeDatabaseForShutdown(runtime, ctx);
|
|
3647
3677
|
clearNativeRuntimeState(runtime, ctx);
|
|
3648
3678
|
}
|
|
3679
|
+
async function detachNativeDatabaseForShutdown(runtime, ctx) {
|
|
3680
|
+
var _a;
|
|
3681
|
+
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3682
|
+
await ((_a = runtimeState.sql) == null ? void 0 : _a.detachForShutdown());
|
|
3683
|
+
try {
|
|
3684
|
+
await closeNativeDatabaseClient(runtime, ctx);
|
|
3685
|
+
} finally {
|
|
3686
|
+
runtimeState.sql = void 0;
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3649
3689
|
function closeNativeSqlDatabase(runtime, ctx) {
|
|
3650
3690
|
const runtimeState = getNativeRuntimeState(runtime, ctx);
|
|
3651
3691
|
const database = runtimeState.sql;
|
|
@@ -3799,10 +3839,10 @@ function decodeValue(value) {
|
|
|
3799
3839
|
if (!value || value.length === 0) {
|
|
3800
3840
|
return void 0;
|
|
3801
3841
|
}
|
|
3802
|
-
return
|
|
3842
|
+
return _chunkIBEFA6CXcjs.decodeCborCompat.call(void 0, value);
|
|
3803
3843
|
}
|
|
3804
3844
|
function encodeValue(value) {
|
|
3805
|
-
return
|
|
3845
|
+
return _chunkIBEFA6CXcjs.encodeCborCompat.call(void 0, value);
|
|
3806
3846
|
}
|
|
3807
3847
|
function normalizeArgs(value) {
|
|
3808
3848
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
@@ -3838,7 +3878,7 @@ function isStructuredBridgeError(error) {
|
|
|
3838
3878
|
return _chunkMGI2VVF6cjs.isRivetErrorLike.call(void 0, error) && "__type" in error && (error.__type === "RivetError" || error.__type === "ActorError");
|
|
3839
3879
|
}
|
|
3840
3880
|
function encodeNativeCallbackError(error) {
|
|
3841
|
-
const structuredError = isStructuredBridgeError(error) ? error :
|
|
3881
|
+
const structuredError = isStructuredBridgeError(error) ? error : _chunkIBEFA6CXcjs.deconstructError.call(void 0, error, true);
|
|
3842
3882
|
const { encoded, droppedMetadataCause } = _chunkMGI2VVF6cjs.encodeBridgeRivetError.call(void 0, structuredError);
|
|
3843
3883
|
if (droppedMetadataCause !== void 0) {
|
|
3844
3884
|
logger2().warn(
|
|
@@ -3900,7 +3940,7 @@ function decodeWorkflowCbor(data) {
|
|
|
3900
3940
|
return null;
|
|
3901
3941
|
}
|
|
3902
3942
|
try {
|
|
3903
|
-
return
|
|
3943
|
+
return _chunkIBEFA6CXcjs.decodeCborCompat.call(void 0, new Uint8Array(data));
|
|
3904
3944
|
} catch (e3) {
|
|
3905
3945
|
return null;
|
|
3906
3946
|
}
|
|
@@ -4013,7 +4053,7 @@ function serializeWorkflowHistoryForJson(data) {
|
|
|
4013
4053
|
if (data === null) {
|
|
4014
4054
|
return null;
|
|
4015
4055
|
}
|
|
4016
|
-
const history =
|
|
4056
|
+
const history = _chunkVCVV726Pcjs.decodeWorkflowHistoryTransport.call(void 0, data);
|
|
4017
4057
|
return jsonSafe({
|
|
4018
4058
|
nameRegistry: [...history.nameRegistry],
|
|
4019
4059
|
entries: history.entries.map((entry) => ({
|
|
@@ -4159,7 +4199,7 @@ var NativeConnAdapter = class {
|
|
|
4159
4199
|
},
|
|
4160
4200
|
(newValue) => {
|
|
4161
4201
|
assertCurrentState();
|
|
4162
|
-
|
|
4202
|
+
_chunkIBEFA6CXcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
4163
4203
|
}
|
|
4164
4204
|
);
|
|
4165
4205
|
}
|
|
@@ -4167,7 +4207,7 @@ var NativeConnAdapter = class {
|
|
|
4167
4207
|
var _a;
|
|
4168
4208
|
(_a = this.#assertCanMutateState) == null ? void 0 : _a.call(this);
|
|
4169
4209
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
4170
|
-
|
|
4210
|
+
_chunkIBEFA6CXcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
4171
4211
|
this.#writeState(nextValue, { writeNative: true });
|
|
4172
4212
|
}
|
|
4173
4213
|
initializeState(value) {
|
|
@@ -4364,7 +4404,7 @@ var NativeKvAdapter = class {
|
|
|
4364
4404
|
const value = await callNative(
|
|
4365
4405
|
() => this.#runtime.actorKvGet(
|
|
4366
4406
|
this.#ctx,
|
|
4367
|
-
|
|
4407
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
|
|
4368
4408
|
)
|
|
4369
4409
|
);
|
|
4370
4410
|
return value ? decodeNativeKvValue(new Uint8Array(value), options) : null;
|
|
@@ -4373,7 +4413,7 @@ var NativeKvAdapter = class {
|
|
|
4373
4413
|
await callNative(
|
|
4374
4414
|
() => this.#runtime.actorKvPut(
|
|
4375
4415
|
this.#ctx,
|
|
4376
|
-
|
|
4416
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key)),
|
|
4377
4417
|
toRuntimeBytes(value)
|
|
4378
4418
|
)
|
|
4379
4419
|
);
|
|
@@ -4382,7 +4422,7 @@ var NativeKvAdapter = class {
|
|
|
4382
4422
|
await callNative(
|
|
4383
4423
|
() => this.#runtime.actorKvDelete(
|
|
4384
4424
|
this.#ctx,
|
|
4385
|
-
|
|
4425
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(key))
|
|
4386
4426
|
)
|
|
4387
4427
|
);
|
|
4388
4428
|
}
|
|
@@ -4390,8 +4430,8 @@ var NativeKvAdapter = class {
|
|
|
4390
4430
|
await callNative(
|
|
4391
4431
|
() => this.#runtime.actorKvDeleteRange(
|
|
4392
4432
|
this.#ctx,
|
|
4393
|
-
|
|
4394
|
-
|
|
4433
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(start)),
|
|
4434
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0, encodeNativeKvUserKey(end))
|
|
4395
4435
|
)
|
|
4396
4436
|
);
|
|
4397
4437
|
}
|
|
@@ -4404,7 +4444,7 @@ var NativeKvAdapter = class {
|
|
|
4404
4444
|
const entries = await callNative(
|
|
4405
4445
|
() => this.#runtime.actorKvListPrefix(
|
|
4406
4446
|
this.#ctx,
|
|
4407
|
-
|
|
4447
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0,
|
|
4408
4448
|
encodeNativeKvUserKey(
|
|
4409
4449
|
prefix,
|
|
4410
4450
|
options == null ? void 0 : options.keyType
|
|
@@ -4418,7 +4458,7 @@ var NativeKvAdapter = class {
|
|
|
4418
4458
|
);
|
|
4419
4459
|
return entries.map((entry) => [
|
|
4420
4460
|
decodeNativeKvKey(
|
|
4421
|
-
|
|
4461
|
+
_chunkRTWH3AX3cjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
|
|
4422
4462
|
options == null ? void 0 : options.keyType
|
|
4423
4463
|
),
|
|
4424
4464
|
decodeNativeKvValue(new Uint8Array(entry.value), options)
|
|
@@ -4437,13 +4477,13 @@ var NativeKvAdapter = class {
|
|
|
4437
4477
|
const entries = await callNative(
|
|
4438
4478
|
() => this.#runtime.actorKvListRange(
|
|
4439
4479
|
this.#ctx,
|
|
4440
|
-
|
|
4480
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0,
|
|
4441
4481
|
encodeNativeKvUserKey(
|
|
4442
4482
|
start,
|
|
4443
4483
|
options == null ? void 0 : options.keyType
|
|
4444
4484
|
)
|
|
4445
4485
|
),
|
|
4446
|
-
|
|
4486
|
+
_chunkRTWH3AX3cjs.makePrefixedKey.call(void 0,
|
|
4447
4487
|
encodeNativeKvUserKey(
|
|
4448
4488
|
end,
|
|
4449
4489
|
options == null ? void 0 : options.keyType
|
|
@@ -4457,7 +4497,7 @@ var NativeKvAdapter = class {
|
|
|
4457
4497
|
);
|
|
4458
4498
|
return entries.map((entry) => [
|
|
4459
4499
|
decodeNativeKvKey(
|
|
4460
|
-
|
|
4500
|
+
_chunkRTWH3AX3cjs.removePrefixFromKey.call(void 0, new Uint8Array(entry.key)),
|
|
4461
4501
|
options == null ? void 0 : options.keyType
|
|
4462
4502
|
),
|
|
4463
4503
|
decodeNativeKvValue(new Uint8Array(entry.value), options)
|
|
@@ -5246,7 +5286,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5246
5286
|
},
|
|
5247
5287
|
(newValue) => {
|
|
5248
5288
|
assertCurrentState();
|
|
5249
|
-
|
|
5289
|
+
_chunkIBEFA6CXcjs.assertJsonCompatValue.call(void 0, newValue);
|
|
5250
5290
|
}
|
|
5251
5291
|
);
|
|
5252
5292
|
}
|
|
@@ -5258,7 +5298,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5258
5298
|
}
|
|
5259
5299
|
this.#assertCanMutateState();
|
|
5260
5300
|
const nextValue = unwrapWriteThroughProxy(value);
|
|
5261
|
-
|
|
5301
|
+
_chunkIBEFA6CXcjs.assertJsonCompatValue.call(void 0, nextValue);
|
|
5262
5302
|
this.#writeState(nextValue, { scheduleSave: true });
|
|
5263
5303
|
}
|
|
5264
5304
|
initializeState(value) {
|
|
@@ -5386,12 +5426,14 @@ var ActorContextHandleAdapter = class {
|
|
|
5386
5426
|
}
|
|
5387
5427
|
get abortSignal() {
|
|
5388
5428
|
if (!this.#abortSignal) {
|
|
5389
|
-
const
|
|
5429
|
+
const actorAbort = this.#actorAbort();
|
|
5430
|
+
const actorSignal = actorAbort.signal;
|
|
5390
5431
|
if (this.#dispatchCancelToken === void 0) {
|
|
5391
5432
|
this.#abortSignal = actorSignal;
|
|
5392
5433
|
} else {
|
|
5393
5434
|
const controller = new AbortController();
|
|
5394
5435
|
let cleanedUp = false;
|
|
5436
|
+
let releaseDispatchListener;
|
|
5395
5437
|
const onActorAbort = () => {
|
|
5396
5438
|
cleanup();
|
|
5397
5439
|
controller.abort();
|
|
@@ -5401,7 +5443,9 @@ var ActorContextHandleAdapter = class {
|
|
|
5401
5443
|
return;
|
|
5402
5444
|
}
|
|
5403
5445
|
cleanedUp = true;
|
|
5404
|
-
|
|
5446
|
+
actorAbort.listeners.delete(onActorAbort);
|
|
5447
|
+
releaseDispatchListener == null ? void 0 : releaseDispatchListener();
|
|
5448
|
+
releaseDispatchListener = void 0;
|
|
5405
5449
|
this.#abortSignalCleanup = void 0;
|
|
5406
5450
|
};
|
|
5407
5451
|
if (actorSignal.aborted || this.#runtime.cancellationTokenAborted(
|
|
@@ -5411,10 +5455,8 @@ var ActorContextHandleAdapter = class {
|
|
|
5411
5455
|
} else {
|
|
5412
5456
|
const dispatchCancelToken = this.#dispatchCancelToken;
|
|
5413
5457
|
this.#abortSignalCleanup = cleanup;
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
});
|
|
5417
|
-
callNativeSync(
|
|
5458
|
+
actorAbort.listeners.add(onActorAbort);
|
|
5459
|
+
releaseDispatchListener = callNativeSync(
|
|
5418
5460
|
() => this.#runtime.onCancellationTokenCancelled(
|
|
5419
5461
|
dispatchCancelToken,
|
|
5420
5462
|
() => {
|
|
@@ -5470,7 +5512,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5470
5512
|
log: {
|
|
5471
5513
|
debug: (obj) => logger2().debug(obj)
|
|
5472
5514
|
},
|
|
5473
|
-
nativeDatabaseProvider:
|
|
5515
|
+
nativeDatabaseProvider: _chunkJLBPBEWCcjs.registerNativeStateTransactionOpener.call(void 0,
|
|
5474
5516
|
{
|
|
5475
5517
|
open: async (requestedActorId) => {
|
|
5476
5518
|
void requestedActorId;
|
|
@@ -5493,7 +5535,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5493
5535
|
return this.#db;
|
|
5494
5536
|
}
|
|
5495
5537
|
#bindDatabaseClient(client) {
|
|
5496
|
-
return
|
|
5538
|
+
return _chunkJLBPBEWCcjs.bindNativeStateTransactionContext.call(void 0, client, {
|
|
5497
5539
|
enter: async () => await this.#enterStateTransaction(),
|
|
5498
5540
|
exit: (scope) => this.#exitStateTransaction(
|
|
5499
5541
|
scope
|
|
@@ -5697,7 +5739,7 @@ var ActorContextHandleAdapter = class {
|
|
|
5697
5739
|
const trackedPromise = Promise.resolve(promise).catch((error) => {
|
|
5698
5740
|
logger2().warn({
|
|
5699
5741
|
msg: "keepAwake promise rejected",
|
|
5700
|
-
error:
|
|
5742
|
+
error: _chunkIBEFA6CXcjs.stringifyError.call(void 0, error)
|
|
5701
5743
|
});
|
|
5702
5744
|
}).then(() => null);
|
|
5703
5745
|
try {
|
|
@@ -5790,22 +5832,42 @@ var ActorContextHandleAdapter = class {
|
|
|
5790
5832
|
}
|
|
5791
5833
|
async dispose() {
|
|
5792
5834
|
var _a;
|
|
5793
|
-
this.#
|
|
5835
|
+
if (!isNativeRuntimeStateCleared(this.#runtime, this.#ctx)) {
|
|
5836
|
+
this.#flushStateChange();
|
|
5837
|
+
}
|
|
5794
5838
|
(_a = this.#abortSignalCleanup) == null ? void 0 : _a.call(this);
|
|
5795
5839
|
}
|
|
5796
|
-
#
|
|
5840
|
+
#actorAbort() {
|
|
5841
|
+
const runtimeState = readNativeRuntimeStateBag(
|
|
5842
|
+
this.#runtime,
|
|
5843
|
+
this.#ctx
|
|
5844
|
+
);
|
|
5845
|
+
const cached = runtimeState.actorAbort;
|
|
5846
|
+
if (cached && !cached.signal.aborted) {
|
|
5847
|
+
return cached;
|
|
5848
|
+
}
|
|
5797
5849
|
const nativeSignal = callNativeSync(
|
|
5798
5850
|
() => this.#runtime.actorAbortSignal(this.#ctx)
|
|
5799
5851
|
);
|
|
5800
5852
|
const controller = new AbortController();
|
|
5801
|
-
|
|
5853
|
+
const actorAbort = {
|
|
5854
|
+
signal: controller.signal,
|
|
5855
|
+
listeners: /* @__PURE__ */ new Set()
|
|
5856
|
+
};
|
|
5857
|
+
const abort = () => {
|
|
5802
5858
|
controller.abort();
|
|
5859
|
+
for (const listener of actorAbort.listeners) {
|
|
5860
|
+
listener();
|
|
5861
|
+
}
|
|
5862
|
+
actorAbort.listeners.clear();
|
|
5863
|
+
};
|
|
5864
|
+
if (nativeSignal.aborted) {
|
|
5865
|
+
abort();
|
|
5803
5866
|
} else {
|
|
5804
|
-
nativeSignal.addEventListener("abort",
|
|
5805
|
-
once: true
|
|
5806
|
-
});
|
|
5867
|
+
nativeSignal.addEventListener("abort", abort, { once: true });
|
|
5807
5868
|
}
|
|
5808
|
-
|
|
5869
|
+
runtimeState.actorAbort = actorAbort;
|
|
5870
|
+
return actorAbort;
|
|
5809
5871
|
}
|
|
5810
5872
|
#readState() {
|
|
5811
5873
|
const actorState = getNativePersistState(this.#runtime, this.#ctx);
|
|
@@ -6175,7 +6237,7 @@ function validateInspectorTabSource(tabId, resolved) {
|
|
|
6175
6237
|
function buildNativeFactory(runtime, registryConfig, definition) {
|
|
6176
6238
|
var _a;
|
|
6177
6239
|
const config = definition.config;
|
|
6178
|
-
const databaseProvider = _nullishCoalesce(config.db, () => (
|
|
6240
|
+
const databaseProvider = _nullishCoalesce(config.db, () => ( _chunkJLBPBEWCcjs.db.call(void 0, )));
|
|
6179
6241
|
const actionHandlers = _chunkHDVZ6YZGcjs.flattenActionHandlers.call(void 0, config.actions);
|
|
6180
6242
|
const schemaConfig = {
|
|
6181
6243
|
actionInputSchemas: _chunkHDVZ6YZGcjs.flattenActionInputSchemas.call(void 0,
|
|
@@ -6186,9 +6248,9 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6186
6248
|
events: config.events,
|
|
6187
6249
|
queues: config.queues
|
|
6188
6250
|
};
|
|
6189
|
-
const createClient = (ctx) =>
|
|
6190
|
-
new (0,
|
|
6191
|
-
|
|
6251
|
+
const createClient = (ctx) => _chunkCTQKKUZCcjs.createClientWithDriver.call(void 0,
|
|
6252
|
+
new (0, _chunkCTQKKUZCcjs.RemoteEngineControlClient)(
|
|
6253
|
+
_chunkCTQKKUZCcjs.convertRegistryConfigToClientConfig.call(void 0, registryConfig)
|
|
6192
6254
|
),
|
|
6193
6255
|
{
|
|
6194
6256
|
encoding: "bare",
|
|
@@ -6380,7 +6442,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6380
6442
|
400
|
|
6381
6443
|
);
|
|
6382
6444
|
}
|
|
6383
|
-
const cbor =
|
|
6445
|
+
const cbor = _chunkIBEFA6CXcjs.encodeCborCompat.call(void 0,
|
|
6384
6446
|
_nullishCoalesce(body.body, () => ( null))
|
|
6385
6447
|
);
|
|
6386
6448
|
const message = await runtime.actorQueueSend(ctx, name, cbor);
|
|
@@ -6767,7 +6829,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6767
6829
|
}
|
|
6768
6830
|
} finally {
|
|
6769
6831
|
resolveNativeDestroy(runtime, ctx);
|
|
6770
|
-
await
|
|
6832
|
+
await detachNativeDatabaseForShutdown(runtime, ctx);
|
|
6771
6833
|
clearNativeRuntimeState(runtime, ctx);
|
|
6772
6834
|
await actorCtx.dispose();
|
|
6773
6835
|
}
|
|
@@ -6977,7 +7039,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
6977
7039
|
...request,
|
|
6978
7040
|
abortController: requestAbortController
|
|
6979
7041
|
});
|
|
6980
|
-
const rawConnParams = handlerRequest.headers.get(
|
|
7042
|
+
const rawConnParams = handlerRequest.headers.get(_chunkCTQKKUZCcjs.HEADER_CONN_PARAMS);
|
|
6981
7043
|
let requestCtx;
|
|
6982
7044
|
let conn;
|
|
6983
7045
|
let removeRequestAbortListener;
|
|
@@ -7034,7 +7096,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7034
7096
|
requestCtx,
|
|
7035
7097
|
handlerRequest
|
|
7036
7098
|
);
|
|
7037
|
-
if (!
|
|
7099
|
+
if (!_chunkCTQKKUZCcjs.isResponseLike.call(void 0, response)) {
|
|
7038
7100
|
throw new Error(
|
|
7039
7101
|
"onRequest handler must return a Response"
|
|
7040
7102
|
);
|
|
@@ -7129,7 +7191,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7129
7191
|
var _a2;
|
|
7130
7192
|
const { ctx } = unwrapTsfnPayload(error, payload);
|
|
7131
7193
|
const history = (_a2 = getNativeWorkflowInspector(ctx)) == null ? void 0 : _a2.getHistory();
|
|
7132
|
-
return history == null ? void 0 :
|
|
7194
|
+
return history == null ? void 0 : _chunkIBEFA6CXcjs.toUint8Array.call(void 0, history);
|
|
7133
7195
|
}
|
|
7134
7196
|
) : void 0,
|
|
7135
7197
|
replayWorkflow: _chunkHDVZ6YZGcjs.hasRunInspectorConfig.call(void 0, config.run) ? wrapNativeCallback(
|
|
@@ -7143,7 +7205,7 @@ function buildNativeFactory(runtime, registryConfig, definition) {
|
|
|
7143
7205
|
return void 0;
|
|
7144
7206
|
}
|
|
7145
7207
|
const history = await _asyncNullishCoalesce(await workflowInspector.replayFromStep(entryId), async () => ( null));
|
|
7146
|
-
return history == null ? void 0 :
|
|
7208
|
+
return history == null ? void 0 : _chunkIBEFA6CXcjs.toUint8Array.call(void 0, history);
|
|
7147
7209
|
}
|
|
7148
7210
|
) : void 0,
|
|
7149
7211
|
actions: Object.fromEntries(
|
|
@@ -7271,15 +7333,16 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
|
7271
7333
|
throw nativeEndpointNotConfiguredError();
|
|
7272
7334
|
}
|
|
7273
7335
|
const serveConfig = {
|
|
7274
|
-
version: config.
|
|
7336
|
+
version: config.node.version,
|
|
7275
7337
|
endpoint: config.endpoint,
|
|
7338
|
+
engineSpawn: config.engineSpawn,
|
|
7276
7339
|
token: config.token,
|
|
7277
7340
|
namespace: config.namespace,
|
|
7278
|
-
poolName: config.
|
|
7341
|
+
poolName: config.node.poolName,
|
|
7279
7342
|
startServices: resolveServicesBinary && config.startServices,
|
|
7280
7343
|
handleInspectorHttpInRuntime: true,
|
|
7281
7344
|
serverlessBasePath: config.serverless.basePath,
|
|
7282
|
-
serverlessPackageVersion:
|
|
7345
|
+
serverlessPackageVersion: _chunkIBEFA6CXcjs.VERSION,
|
|
7283
7346
|
serverlessClientEndpoint: config.publicEndpoint,
|
|
7284
7347
|
serverlessClientNamespace: config.publicNamespace,
|
|
7285
7348
|
serverlessClientToken: config.publicToken,
|
|
@@ -7292,30 +7355,32 @@ async function buildServeConfig(config, resolveServicesBinary = true) {
|
|
|
7292
7355
|
} catch (error) {
|
|
7293
7356
|
logger2().warn({
|
|
7294
7357
|
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:
|
|
7358
|
+
error: _chunkIBEFA6CXcjs.stringifyError.call(void 0, error)
|
|
7296
7359
|
});
|
|
7297
7360
|
}
|
|
7298
7361
|
if (resolveServicesBinary && config.startServices) {
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
serveConfig.servicesBinaryPath =
|
|
7302
|
-
}
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
})
|
|
7362
|
+
const servicesBinary = _chunkIBEFA6CXcjs.getEnvUniversal.call(void 0, "RIVET_SERVICES_BINARY");
|
|
7363
|
+
if (servicesBinary) {
|
|
7364
|
+
serveConfig.servicesBinaryPath = servicesBinary;
|
|
7365
|
+
} else {
|
|
7366
|
+
try {
|
|
7367
|
+
const { getServicesPath } = await loadServices();
|
|
7368
|
+
serveConfig.servicesBinaryPath = getServicesPath();
|
|
7369
|
+
} catch (error) {
|
|
7370
|
+
throw servicesBinaryUnavailable(error);
|
|
7371
|
+
}
|
|
7307
7372
|
}
|
|
7308
7373
|
}
|
|
7309
7374
|
serveConfig.engineHost = config.engineHost;
|
|
7310
7375
|
serveConfig.enginePort = config.enginePort;
|
|
7311
7376
|
if ((_a = config.test) == null ? void 0 : _a.enabled) {
|
|
7312
|
-
serveConfig.inspectorTestToken = _nullishCoalesce(
|
|
7377
|
+
serveConfig.inspectorTestToken = _nullishCoalesce(_chunkIBEFA6CXcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN"), () => ( "token"));
|
|
7313
7378
|
}
|
|
7314
7379
|
return serveConfig;
|
|
7315
7380
|
}
|
|
7316
7381
|
async function buildRegistryWithRuntime(config, runtime) {
|
|
7317
7382
|
var _a;
|
|
7318
|
-
if (((_a = config.test) == null ? void 0 : _a.enabled) &&
|
|
7383
|
+
if (((_a = config.test) == null ? void 0 : _a.enabled) && _chunkIBEFA6CXcjs.getEnvUniversal.call(void 0, "_RIVET_TEST_INSPECTOR_TOKEN") === void 0) {
|
|
7319
7384
|
trySetProcessEnv("_RIVET_TEST_INSPECTOR_TOKEN", "token");
|
|
7320
7385
|
}
|
|
7321
7386
|
if (runtime.kind === "napi") {
|
|
@@ -7345,6 +7410,9 @@ async function buildConfiguredRegistry(config) {
|
|
|
7345
7410
|
|
|
7346
7411
|
// src/registry/index.ts
|
|
7347
7412
|
var REGISTRY_READY_TIMEOUT_MS = 3e4;
|
|
7413
|
+
function rejectServerless() {
|
|
7414
|
+
throw new Error("serverless is disabled in this version");
|
|
7415
|
+
}
|
|
7348
7416
|
function signalExitCode(signal) {
|
|
7349
7417
|
switch (signal) {
|
|
7350
7418
|
case "SIGINT":
|
|
@@ -7382,7 +7450,7 @@ function createApplicationFetch(application, runtime) {
|
|
|
7382
7450
|
signal: abortController.signal
|
|
7383
7451
|
})
|
|
7384
7452
|
);
|
|
7385
|
-
if (!
|
|
7453
|
+
if (!_chunkCTQKKUZCcjs.isResponseLike.call(void 0, response)) {
|
|
7386
7454
|
throw new TypeError(
|
|
7387
7455
|
"registry.listen() application fetch must return a Response"
|
|
7388
7456
|
);
|
|
@@ -7432,7 +7500,7 @@ var Registry = class {
|
|
|
7432
7500
|
var _a;
|
|
7433
7501
|
this.#config = config;
|
|
7434
7502
|
if ((_a = config.logging) == null ? void 0 : _a.baseLogger) {
|
|
7435
|
-
|
|
7503
|
+
_chunkIBEFA6CXcjs.configureBaseLogger.call(void 0, config.logging.baseLogger);
|
|
7436
7504
|
}
|
|
7437
7505
|
this.#buildConfiguredRegistry = _nullishCoalesce((deps == null ? void 0 : deps.buildConfiguredRegistry), () => ( buildConfiguredRegistry));
|
|
7438
7506
|
this.routes = {
|
|
@@ -7449,6 +7517,7 @@ var Registry = class {
|
|
|
7449
7517
|
*/
|
|
7450
7518
|
#ensureServerlessPoolConfigured(config) {
|
|
7451
7519
|
if (!config.configurePool) return void 0;
|
|
7520
|
+
rejectServerless();
|
|
7452
7521
|
if (!this.#configureServerlessPoolPromise) {
|
|
7453
7522
|
this.#configureServerlessPoolPromise = configureServerlessPool(
|
|
7454
7523
|
config
|
|
@@ -7473,6 +7542,7 @@ var Registry = class {
|
|
|
7473
7542
|
*/
|
|
7474
7543
|
async handler(request) {
|
|
7475
7544
|
var _a;
|
|
7545
|
+
rejectServerless();
|
|
7476
7546
|
const config = this.parseConfig();
|
|
7477
7547
|
this.#printWelcome(config, "serverless");
|
|
7478
7548
|
if (!this.#runtimeServerlessPromise) {
|
|
@@ -7634,6 +7704,7 @@ var Registry = class {
|
|
|
7634
7704
|
* ```
|
|
7635
7705
|
*/
|
|
7636
7706
|
serve() {
|
|
7707
|
+
rejectServerless();
|
|
7637
7708
|
return {
|
|
7638
7709
|
fetch: (request) => this.handler(request)
|
|
7639
7710
|
};
|
|
@@ -7658,10 +7729,13 @@ var Registry = class {
|
|
|
7658
7729
|
* ```
|
|
7659
7730
|
*/
|
|
7660
7731
|
async listen(opts = {}) {
|
|
7661
|
-
|
|
7662
|
-
|
|
7732
|
+
if (!opts.application) {
|
|
7733
|
+
rejectServerless();
|
|
7734
|
+
}
|
|
7735
|
+
const port = _nullishCoalesce(_nullishCoalesce(opts.port, () => ( _chunkIBEFA6CXcjs.parsePortEnv.call(void 0, process.env.RIVET_PORT))), () => ( 3e3));
|
|
7736
|
+
const publicDir = _nullishCoalesce(opts.publicDir, () => ( _chunkIBEFA6CXcjs.getRivetkitPublicDir.call(void 0, )));
|
|
7663
7737
|
const config = this.parseConfig();
|
|
7664
|
-
if (opts.application &&
|
|
7738
|
+
if (opts.application && _chunkIBEFA6CXcjs.getRivetkitRuntimeMode.call(void 0, ) !== "serverless") {
|
|
7665
7739
|
if (config.runtime === "wasm") {
|
|
7666
7740
|
throw new Error(
|
|
7667
7741
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly"
|
|
@@ -7737,7 +7811,7 @@ var Registry = class {
|
|
|
7737
7811
|
return jsonRouteResponse(503, {
|
|
7738
7812
|
status: "not_started",
|
|
7739
7813
|
runtime: "rivetkit",
|
|
7740
|
-
version:
|
|
7814
|
+
version: _chunkIBEFA6CXcjs.VERSION
|
|
7741
7815
|
});
|
|
7742
7816
|
}
|
|
7743
7817
|
const { runtime, registry } = configured;
|
|
@@ -7745,7 +7819,7 @@ var Registry = class {
|
|
|
7745
7819
|
return jsonRouteResponse(501, {
|
|
7746
7820
|
status: "unsupported",
|
|
7747
7821
|
runtime: "rivetkit",
|
|
7748
|
-
version:
|
|
7822
|
+
version: _chunkIBEFA6CXcjs.VERSION
|
|
7749
7823
|
});
|
|
7750
7824
|
}
|
|
7751
7825
|
const response = await runtime.registryHealth(registry);
|
|
@@ -7758,6 +7832,7 @@ var Registry = class {
|
|
|
7758
7832
|
* Returns serverless metadata suitable for mounting in a user-owned router.
|
|
7759
7833
|
*/
|
|
7760
7834
|
async #metadataRoute() {
|
|
7835
|
+
rejectServerless();
|
|
7761
7836
|
const configured = await this.#activeConfiguredRegistry();
|
|
7762
7837
|
if (!configured) {
|
|
7763
7838
|
return new Response("registry not started\n", {
|
|
@@ -7818,18 +7893,18 @@ var Registry = class {
|
|
|
7818
7893
|
#startEnvoy(config, printWelcome) {
|
|
7819
7894
|
var _a;
|
|
7820
7895
|
if (!this.#runtimeServePromise) {
|
|
7821
|
-
const configuredEnvoyVersion = (_a = this.#config.
|
|
7822
|
-
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" :
|
|
7896
|
+
const configuredEnvoyVersion = (_a = this.#config.node) == null ? void 0 : _a.version;
|
|
7897
|
+
const envoyVersionSource = configuredEnvoyVersion !== void 0 ? "config" : _chunkIBEFA6CXcjs.getRivetEnvoyVersion.call(void 0, ) !== void 0 ? "environment" : "default";
|
|
7823
7898
|
logger2().info({
|
|
7824
7899
|
msg: "starting rivetkit envoy",
|
|
7825
|
-
rivetkitVersion:
|
|
7826
|
-
envoyVersion: config.
|
|
7900
|
+
rivetkitVersion: _chunkIBEFA6CXcjs.VERSION,
|
|
7901
|
+
envoyVersion: config.node.version,
|
|
7827
7902
|
envoyVersionSource
|
|
7828
7903
|
});
|
|
7829
|
-
if (envoyVersionSource === "default" &&
|
|
7904
|
+
if (envoyVersionSource === "default" && _chunkIBEFA6CXcjs.getNodeEnv.call(void 0, ) === "production") {
|
|
7830
7905
|
logger2().error({
|
|
7831
|
-
msg: "
|
|
7832
|
-
envoyVersion: config.
|
|
7906
|
+
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",
|
|
7907
|
+
envoyVersion: config.node.version,
|
|
7833
7908
|
envoyVersionSource
|
|
7834
7909
|
});
|
|
7835
7910
|
}
|
|
@@ -7841,7 +7916,10 @@ var Registry = class {
|
|
|
7841
7916
|
}
|
|
7842
7917
|
);
|
|
7843
7918
|
this.#runtimeServePromise = this.#runtimeServeLifecyclePromise.catch((error) => {
|
|
7844
|
-
logger2().
|
|
7919
|
+
logger2().error({ error }, "runtime registry serve errored");
|
|
7920
|
+
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
7921
|
+
process.exit(1);
|
|
7922
|
+
}
|
|
7845
7923
|
});
|
|
7846
7924
|
this.#installSignalHandlers(config);
|
|
7847
7925
|
}
|
|
@@ -7871,7 +7949,7 @@ var Registry = class {
|
|
|
7871
7949
|
finishShutdownSignal(signal);
|
|
7872
7950
|
return;
|
|
7873
7951
|
}
|
|
7874
|
-
this.#shutdownInFlight = this.#drain(config).catch((err) => {
|
|
7952
|
+
this.#shutdownInFlight = this.#drain(config, true).catch((err) => {
|
|
7875
7953
|
logger2().warn({ err }, "shutdown error");
|
|
7876
7954
|
}).then(() => {
|
|
7877
7955
|
this.#removeSignalHandlers();
|
|
@@ -7907,12 +7985,18 @@ var Registry = class {
|
|
|
7907
7985
|
});
|
|
7908
7986
|
return this.#shutdownInFlight;
|
|
7909
7987
|
}
|
|
7910
|
-
async #drain(config) {
|
|
7988
|
+
async #drain(config, signalDriven = false) {
|
|
7911
7989
|
var _a;
|
|
7912
7990
|
const modeAPromise = this.#runtimeServeConfiguredPromise;
|
|
7913
7991
|
const modeBPromise = this.#runtimeServerlessPromise;
|
|
7914
7992
|
const runtimes = /* @__PURE__ */ new Set();
|
|
7915
|
-
const
|
|
7993
|
+
const localDevSignal = signalDriven && _chunkIBEFA6CXcjs.getNodeEnv.call(void 0, ) !== "production" && config.engineSpawn && config.endpoint !== void 0 && _chunkCTQKKUZCcjs.isLocalEngineEndpoint.call(void 0, config.endpoint);
|
|
7994
|
+
let gracePeriodMs = (_a = config.shutdown) == null ? void 0 : _a.gracePeriodMs;
|
|
7995
|
+
if (gracePeriodMs === void 0) {
|
|
7996
|
+
gracePeriodMs = localDevSignal ? 1e3 : await _asyncNullishCoalesce(await this.#actorStopThresholdMs(
|
|
7997
|
+
_nullishCoalesce(modeAPromise, () => ( modeBPromise))
|
|
7998
|
+
), async () => ( 30 * 60 * 1e3));
|
|
7999
|
+
}
|
|
7916
8000
|
const drain = async () => {
|
|
7917
8001
|
const registries = [];
|
|
7918
8002
|
if (modeAPromise !== void 0) {
|
|
@@ -8017,12 +8101,16 @@ var Registry = class {
|
|
|
8017
8101
|
);
|
|
8018
8102
|
}
|
|
8019
8103
|
if (this.#runtimeReadyPromise) return this.#runtimeReadyPromise;
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8104
|
+
try {
|
|
8105
|
+
if (_chunkIBEFA6CXcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8106
|
+
return Promise.reject(
|
|
8107
|
+
new Error(
|
|
8108
|
+
"registry.startAndWait() requires envoy runtime mode; serverless registries become ready per request"
|
|
8109
|
+
)
|
|
8110
|
+
);
|
|
8111
|
+
}
|
|
8112
|
+
} catch (error) {
|
|
8113
|
+
return Promise.reject(error);
|
|
8026
8114
|
}
|
|
8027
8115
|
const config = this.parseConfig();
|
|
8028
8116
|
if (config.runtime === "wasm") {
|
|
@@ -8087,8 +8175,8 @@ var Registry = class {
|
|
|
8087
8175
|
* ```
|
|
8088
8176
|
*/
|
|
8089
8177
|
start() {
|
|
8090
|
-
if (
|
|
8091
|
-
const publicDir = _nullishCoalesce(
|
|
8178
|
+
if (_chunkIBEFA6CXcjs.getRivetkitRuntimeMode.call(void 0, ) === "serverless") {
|
|
8179
|
+
const publicDir = _nullishCoalesce(_chunkIBEFA6CXcjs.getRivetkitPublicDir.call(void 0, ), () => ( "/public"));
|
|
8092
8180
|
this.listen({ publicDir }).catch((error) => {
|
|
8093
8181
|
logger2().error({ error }, "auto-listen failed; exiting");
|
|
8094
8182
|
if (typeof process !== "undefined" && typeof process.exit === "function") {
|
|
@@ -8109,13 +8197,13 @@ var Registry = class {
|
|
|
8109
8197
|
};
|
|
8110
8198
|
console.log();
|
|
8111
8199
|
console.log(
|
|
8112
|
-
` RivetKit ${
|
|
8200
|
+
` RivetKit ${_chunkIBEFA6CXcjs.VERSION} (Engine - ${kind === "serverless" ? "Serverless" : "Serverful"})`
|
|
8113
8201
|
);
|
|
8114
8202
|
if (config.namespace !== "default") {
|
|
8115
8203
|
logLine("Namespace", config.namespace);
|
|
8116
8204
|
}
|
|
8117
8205
|
if (config.endpoint) {
|
|
8118
|
-
const endpointType = config.startEngine ||
|
|
8206
|
+
const endpointType = config.startEngine || _chunkCTQKKUZCcjs.isLocalEngineEndpoint.call(void 0, config.endpoint) ? "local native" : "remote";
|
|
8119
8207
|
logLine("Endpoint", `${config.endpoint} (${endpointType})`);
|
|
8120
8208
|
}
|
|
8121
8209
|
if (kind === "serverless" && config.publicEndpoint) {
|
|
@@ -8185,5 +8273,5 @@ function setup(input) {
|
|
|
8185
8273
|
|
|
8186
8274
|
|
|
8187
8275
|
|
|
8188
|
-
exports.ALLOWED_PUBLIC_HEADERS =
|
|
8276
|
+
exports.ALLOWED_PUBLIC_HEADERS = _chunkCTQKKUZCcjs.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 = _chunkCTQKKUZCcjs.createClientWithDriver; exports.defineRunHandler = _chunkHDVZ6YZGcjs.defineRunHandler; exports.event = event; exports.isStaticActorDefinition = isStaticActorDefinition; exports.isStaticActorInstance = isStaticActorInstance; exports.lookupInRegistry = lookupInRegistry; exports.noopNext = _chunkIBEFA6CXcjs.noopNext; exports.queue = queue; exports.setup = setup; exports.toUint8Array = _chunkIBEFA6CXcjs.toUint8Array;
|
|
8189
8277
|
//# sourceMappingURL=mod.cjs.map
|