rivetkit 3.1.2-rc.4 → 3.1.2-rc.6
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 +16 -2
- package/dist/browser/client.js +1 -9
- package/dist/browser/client.js.map +1 -1
- package/dist/browser/inspector/client.js +1 -1
- package/dist/browser/inspector/client.js.map +1 -1
- package/dist/tsup/{chunk-UWN46MY2.js → chunk-2OEJM5K3.js} +2 -2
- package/dist/tsup/{chunk-UWN46MY2.js.map → chunk-2OEJM5K3.js.map} +1 -1
- package/dist/tsup/{chunk-YCGI3WIV.js → chunk-4GCDILHQ.js} +2 -2
- package/dist/tsup/{chunk-Z367MDQC.cjs → chunk-7EDYE6RS.cjs} +147 -155
- package/dist/tsup/chunk-7EDYE6RS.cjs.map +1 -0
- package/dist/tsup/{chunk-J6FABVZY.cjs → chunk-AKADRXK5.cjs} +3 -3
- package/dist/tsup/{chunk-J6FABVZY.cjs.map → chunk-AKADRXK5.cjs.map} +1 -1
- package/dist/tsup/{chunk-YJWR3YQX.js → chunk-AUC22H3Q.js} +4 -4
- package/dist/tsup/{chunk-OJ37CYEU.js → chunk-GPNKYTKX.js} +2 -2
- package/dist/tsup/{chunk-6476KISG.js → chunk-HEWH252Y.js} +2 -2
- package/dist/tsup/{chunk-VWIV375X.cjs → chunk-JHBRUK2G.cjs} +2 -2
- package/dist/tsup/{chunk-VWIV375X.cjs.map → chunk-JHBRUK2G.cjs.map} +1 -1
- package/dist/tsup/{chunk-6AD2HIBH.cjs → chunk-KCL4AISR.cjs} +4 -4
- package/dist/tsup/{chunk-6AD2HIBH.cjs.map → chunk-KCL4AISR.cjs.map} +1 -1
- package/dist/tsup/{chunk-S26YAPYA.js → chunk-LFGYDRKK.js} +2 -2
- package/dist/tsup/{chunk-QSO2JLX2.cjs → chunk-NHTD4LYE.cjs} +3 -3
- package/dist/tsup/{chunk-QSO2JLX2.cjs.map → chunk-NHTD4LYE.cjs.map} +1 -1
- package/dist/tsup/{chunk-OS3NPWVL.js → chunk-O6BVKXY4.js} +6 -14
- package/dist/tsup/chunk-O6BVKXY4.js.map +1 -0
- package/dist/tsup/{chunk-2NDVJNGH.cjs → chunk-V32FXQ3Y.cjs} +3 -3
- package/dist/tsup/{chunk-2NDVJNGH.cjs.map → chunk-V32FXQ3Y.cjs.map} +1 -1
- package/dist/tsup/{chunk-P3P4I45V.cjs → chunk-X3EPJHTD.cjs} +7 -7
- package/dist/tsup/{chunk-P3P4I45V.cjs.map → chunk-X3EPJHTD.cjs.map} +1 -1
- package/dist/tsup/{chunk-WJA6TRRE.cjs → chunk-X7HD5E4N.cjs} +10 -10
- package/dist/tsup/{chunk-WJA6TRRE.cjs.map → chunk-X7HD5E4N.cjs.map} +1 -1
- package/dist/tsup/{chunk-NSAMWM3A.js → chunk-Y5RH2IT6.js} +3 -3
- package/dist/tsup/client/mod.cjs +5 -5
- package/dist/tsup/client/mod.d.cts +2 -2
- package/dist/tsup/client/mod.d.ts +2 -2
- package/dist/tsup/client/mod.js +4 -4
- package/dist/tsup/common/log.cjs +2 -2
- package/dist/tsup/common/log.js +1 -1
- package/dist/tsup/common/websocket.cjs +3 -3
- package/dist/tsup/common/websocket.js +2 -2
- package/dist/tsup/{config-BbRMYCV8.d.cts → config-BMGUEKMZ.d.cts} +16 -2
- package/dist/tsup/{config-CW3AWqHa.d.ts → config-iBpXyITj.d.ts} +16 -2
- package/dist/tsup/{context-Cp64yaMW.d.ts → context-hyVakgnU.d.ts} +1 -1
- package/dist/tsup/{context-NuwP8HjQ.d.cts → context-qfvLuF0P.d.cts} +1 -1
- package/dist/tsup/db/drizzle.cjs +2 -2
- package/dist/tsup/db/drizzle.js +1 -1
- package/dist/tsup/db/mod.cjs +3 -3
- package/dist/tsup/db/mod.js +2 -2
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +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.d.cts +2 -2
- package/dist/tsup/inspector-tab/mod.d.ts +2 -2
- package/dist/tsup/mod.cjs +391 -127
- package/dist/tsup/mod.cjs.map +1 -1
- package/dist/tsup/mod.d.cts +3 -3
- package/dist/tsup/mod.d.ts +3 -3
- package/dist/tsup/mod.js +310 -46
- package/dist/tsup/mod.js.map +1 -1
- package/dist/tsup/test/mod.cjs +6 -6
- package/dist/tsup/test/mod.d.cts +1 -1
- package/dist/tsup/test/mod.d.ts +1 -1
- package/dist/tsup/test/mod.js +4 -4
- package/dist/tsup/utils.cjs +2 -2
- package/dist/tsup/utils.js +1 -1
- package/dist/tsup/workflow/mod.cjs +7 -7
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +4 -4
- package/package.json +9 -9
- package/src/client/lifecycle-errors.ts +0 -15
- package/src/common/database/config.ts +52 -0
- package/src/common/database/native-database.ts +229 -18
- package/src/registry/config/index.ts +1 -3
- package/src/registry/index.ts +14 -15
- package/src/registry/napi-runtime.ts +81 -2
- package/src/registry/native.ts +66 -17
- package/src/registry/runtime.ts +53 -2
- package/src/registry/wasm-runtime.ts +88 -0
- package/dist/tsup/chunk-OS3NPWVL.js.map +0 -1
- package/dist/tsup/chunk-Z367MDQC.cjs.map +0 -1
- /package/dist/tsup/{chunk-YCGI3WIV.js.map → chunk-4GCDILHQ.js.map} +0 -0
- /package/dist/tsup/{chunk-YJWR3YQX.js.map → chunk-AUC22H3Q.js.map} +0 -0
- /package/dist/tsup/{chunk-OJ37CYEU.js.map → chunk-GPNKYTKX.js.map} +0 -0
- /package/dist/tsup/{chunk-6476KISG.js.map → chunk-HEWH252Y.js.map} +0 -0
- /package/dist/tsup/{chunk-S26YAPYA.js.map → chunk-LFGYDRKK.js.map} +0 -0
- /package/dist/tsup/{chunk-NSAMWM3A.js.map → chunk-Y5RH2IT6.js.map} +0 -0
package/dist/tsup/test/mod.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkX3EPJHTDcjs = require('../chunk-X3EPJHTD.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk7EDYE6RScjs = require('../chunk-7EDYE6RS.cjs');
|
|
7
7
|
require('../chunk-RTWH3AX3.cjs');
|
|
8
|
+
require('../chunk-NHTD4LYE.cjs');
|
|
8
9
|
require('../chunk-KVFIONKQ.cjs');
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-VWIV375X.cjs');
|
|
10
|
+
require('../chunk-JHBRUK2G.cjs');
|
|
11
11
|
require('../chunk-MGI2VVF6.cjs');
|
|
12
12
|
|
|
13
13
|
// src/test/ready.ts
|
|
@@ -36,8 +36,8 @@ async function setupTest(c, registry) {
|
|
|
36
36
|
registry.config.noWelcome = true;
|
|
37
37
|
registry.start();
|
|
38
38
|
await waitForRegistryReady(registry);
|
|
39
|
-
const client =
|
|
40
|
-
...
|
|
39
|
+
const client = _chunkX3EPJHTDcjs.createClient.call(void 0, {
|
|
40
|
+
..._chunk7EDYE6RScjs.convertRegistryConfigToClientConfig.call(void 0, registry.parseConfig()),
|
|
41
41
|
disableMetadataLookup: false
|
|
42
42
|
});
|
|
43
43
|
c.onTestFinished(async () => {
|
package/dist/tsup/test/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import { aK as Registry, a8 as Client } from '../config-
|
|
2
|
+
import { aK as Registry, a8 as Client } from '../config-BMGUEKMZ.cjs';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '../config-CBTr4IhE.cjs';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
package/dist/tsup/test/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestContext } from 'vitest';
|
|
2
|
-
import { aK as Registry, a8 as Client } from '../config-
|
|
2
|
+
import { aK as Registry, a8 as Client } from '../config-iBpXyITj.js';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '../config-CBTr4IhE.js';
|
|
5
5
|
import '@rivetkit/rivetkit-wasm';
|
package/dist/tsup/test/mod.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-Y5RH2IT6.js";
|
|
4
4
|
import {
|
|
5
5
|
convertRegistryConfigToClientConfig
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-O6BVKXY4.js";
|
|
7
7
|
import "../chunk-A2CF6PFH.js";
|
|
8
|
+
import "../chunk-GPNKYTKX.js";
|
|
8
9
|
import "../chunk-JTHHCZCZ.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-UWN46MY2.js";
|
|
10
|
+
import "../chunk-2OEJM5K3.js";
|
|
11
11
|
import "../chunk-ZOVJDAOW.js";
|
|
12
12
|
|
|
13
13
|
// src/test/ready.ts
|
package/dist/tsup/utils.cjs
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _chunkJHBRUK2Gcjs = require('./chunk-JHBRUK2G.cjs');
|
|
23
23
|
require('./chunk-MGI2VVF6.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
@@ -42,5 +42,5 @@ require('./chunk-MGI2VVF6.cjs');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.EXTRA_ERROR_LOG =
|
|
45
|
+
exports.EXTRA_ERROR_LOG = _chunkJHBRUK2Gcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkJHBRUK2Gcjs.SinglePromiseQueue; exports.VERSION = _chunkJHBRUK2Gcjs.VERSION; exports.arrayBuffersEqual = _chunkJHBRUK2Gcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkJHBRUK2Gcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkJHBRUK2Gcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkJHBRUK2Gcjs.combineUrlPath; exports.dbg = _chunkJHBRUK2Gcjs.dbg; exports.detectRuntime = _chunkJHBRUK2Gcjs.detectRuntime; exports.getEnvUniversal = _chunkJHBRUK2Gcjs.getEnvUniversal; exports.httpUserAgent = _chunkJHBRUK2Gcjs.httpUserAgent; exports.interval = _chunkJHBRUK2Gcjs.interval; exports.joinSignals = _chunkJHBRUK2Gcjs.joinSignals; exports.jsonParseCompat = _chunkJHBRUK2Gcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkJHBRUK2Gcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkJHBRUK2Gcjs.promiseWithResolvers; exports.setLongTimeout = _chunkJHBRUK2Gcjs.setLongTimeout; exports.sleep = _chunkJHBRUK2Gcjs.sleep; exports.stringifyError = _chunkJHBRUK2Gcjs.stringifyError; exports.toUint8Array = _chunkJHBRUK2Gcjs.toUint8Array;
|
|
46
46
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/tsup/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } var _class; var _class2;
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
3
|
+
var _chunkX7HD5E4Ncjs = require('../chunk-X7HD5E4N.cjs');
|
|
4
|
+
require('../chunk-AKADRXK5.cjs');
|
|
5
|
+
require('../chunk-KCL4AISR.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ var _chunkAQJFKHBKcjs = require('../chunk-AQJFKHBK.cjs');
|
|
|
13
13
|
var _chunkRTWH3AX3cjs = require('../chunk-RTWH3AX3.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkJHBRUK2Gcjs = require('../chunk-JHBRUK2G.cjs');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -769,7 +769,7 @@ function workflow(fn, options = {}) {
|
|
|
769
769
|
function getWorkflowInspector(actorId) {
|
|
770
770
|
let workflowInspector = workflowInspectors.get(actorId);
|
|
771
771
|
if (!workflowInspector) {
|
|
772
|
-
workflowInspector =
|
|
772
|
+
workflowInspector = _chunkX7HD5E4Ncjs.createWorkflowInspectorAdapter.call(void 0, );
|
|
773
773
|
workflowInspectors.set(actorId, workflowInspector);
|
|
774
774
|
}
|
|
775
775
|
return workflowInspector;
|
|
@@ -842,13 +842,13 @@ function workflow(fn, options = {}) {
|
|
|
842
842
|
if (shouldRethrowWorkflowError(error)) {
|
|
843
843
|
runCtx.log.error({
|
|
844
844
|
msg: "workflow run failed",
|
|
845
|
-
error:
|
|
845
|
+
error: _chunkJHBRUK2Gcjs.stringifyError.call(void 0, error)
|
|
846
846
|
});
|
|
847
847
|
throw error;
|
|
848
848
|
}
|
|
849
849
|
runCtx.log.warn({
|
|
850
850
|
msg: "workflow failed and will sleep until woken",
|
|
851
|
-
error:
|
|
851
|
+
error: _chunkJHBRUK2Gcjs.stringifyError.call(void 0, error)
|
|
852
852
|
});
|
|
853
853
|
} finally {
|
|
854
854
|
runCtx.abortSignal.removeEventListener("abort", onAbort);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
2
2
|
export { Loop, TryBlockCatchKind, TryBlockConfig, TryBlockFailure, TryBlockResult, TryStepCatchKind, TryStepConfig, TryStepFailure, TryStepResult, WorkflowError, WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
3
|
-
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-
|
|
3
|
+
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-BMGUEKMZ.cjs';
|
|
4
4
|
import { A as AnyDatabaseProvider } from '../config-CBTr4IhE.cjs';
|
|
5
|
-
import { d as WorkflowContext } from '../context-
|
|
6
|
-
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-
|
|
5
|
+
import { d as WorkflowContext } from '../context-qfvLuF0P.cjs';
|
|
6
|
+
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-qfvLuF0P.cjs';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@rivetkit/rivetkit-wasm';
|
|
9
9
|
import 'zod';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
2
2
|
export { Loop, TryBlockCatchKind, TryBlockConfig, TryBlockFailure, TryBlockResult, TryStepCatchKind, TryStepConfig, TryStepFailure, TryStepResult, WorkflowError, WorkflowErrorEvent } from '@rivetkit/workflow-engine';
|
|
3
|
-
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-
|
|
3
|
+
import { E as EventSchemaConfig, Q as QueueSchemaConfig, h as RunContext } from '../config-iBpXyITj.js';
|
|
4
4
|
import { A as AnyDatabaseProvider } from '../config-CBTr4IhE.js';
|
|
5
|
-
import { d as WorkflowContext } from '../context-
|
|
6
|
-
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-
|
|
5
|
+
import { d as WorkflowContext } from '../context-hyVakgnU.js';
|
|
6
|
+
export { e as WorkflowBranchConfig, W as WorkflowBranchContextOf, a as WorkflowContextOf, f as WorkflowLoopConfig, b as WorkflowLoopContextOf, g as WorkflowStepConfig, h as WorkflowStepContext, c as WorkflowStepContextOf, i as WorkflowTryConfig, j as WorkflowTryStepConfig } from '../context-hyVakgnU.js';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@rivetkit/rivetkit-wasm';
|
|
9
9
|
import 'zod';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createWorkflowInspectorAdapter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-AUC22H3Q.js";
|
|
4
|
+
import "../chunk-4GCDILHQ.js";
|
|
5
|
+
import "../chunk-LFGYDRKK.js";
|
|
6
6
|
import {
|
|
7
7
|
ACTOR_CONTEXT_INTERNAL_SYMBOL,
|
|
8
8
|
defineRunHandler
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "../chunk-A2CF6PFH.js";
|
|
14
14
|
import {
|
|
15
15
|
stringifyError
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-2OEJM5K3.js";
|
|
17
17
|
import {
|
|
18
18
|
RivetError,
|
|
19
19
|
isActorAbortedError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivetkit",
|
|
3
|
-
"version": "3.1.2-rc.
|
|
3
|
+
"version": "3.1.2-rc.6",
|
|
4
4
|
"description": "Lightweight libraries for building stateful actors on edge platforms",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -211,15 +211,15 @@
|
|
|
211
211
|
"@hono/zod-openapi": "^1.1.5",
|
|
212
212
|
"@opentelemetry/api": "^1.1.0",
|
|
213
213
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
214
|
-
"@rivetkit/engine-api-full": "3.1.2-rc.
|
|
215
|
-
"@rivetkit/engine-cli": "3.1.2-rc.
|
|
216
|
-
"@rivetkit/engine-envoy-protocol": "3.1.2-rc.
|
|
214
|
+
"@rivetkit/engine-api-full": "3.1.2-rc.6",
|
|
215
|
+
"@rivetkit/engine-cli": "3.1.2-rc.6",
|
|
216
|
+
"@rivetkit/engine-envoy-protocol": "3.1.2-rc.6",
|
|
217
217
|
"@rivetkit/on-change": "6.0.1",
|
|
218
|
-
"@rivetkit/rivetkit-napi": "3.1.2-rc.
|
|
219
|
-
"@rivetkit/rivetkit-wasm": "3.1.2-rc.
|
|
220
|
-
"@rivetkit/traces": "3.1.2-rc.
|
|
221
|
-
"@rivetkit/virtual-websocket": "3.1.2-rc.
|
|
222
|
-
"@rivetkit/workflow-engine": "3.1.2-rc.
|
|
218
|
+
"@rivetkit/rivetkit-napi": "3.1.2-rc.6",
|
|
219
|
+
"@rivetkit/rivetkit-wasm": "3.1.2-rc.6",
|
|
220
|
+
"@rivetkit/traces": "3.1.2-rc.6",
|
|
221
|
+
"@rivetkit/virtual-websocket": "3.1.2-rc.6",
|
|
222
|
+
"@rivetkit/workflow-engine": "3.1.2-rc.6",
|
|
223
223
|
"cbor-x": "^1.6.0",
|
|
224
224
|
"drizzle-orm": "0.45.2",
|
|
225
225
|
"hono": "^4.7.0",
|
|
@@ -82,21 +82,6 @@ function classifyActorError(
|
|
|
82
82
|
);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// Storage refused the actor's write before running it, as when a new actor's startup commit
|
|
86
|
-
// is shed under load. The connection may open again after the hint the close carried, but
|
|
87
|
-
// an action that failed this way already ran its handler, so it is not sent again.
|
|
88
|
-
if (
|
|
89
|
-
(error.group === "sqlite" && error.code === "storage_overloaded") ||
|
|
90
|
-
(error.group === "depot" && error.code === "overloaded")
|
|
91
|
-
) {
|
|
92
|
-
return buildLifecycleBoundaryInfo(
|
|
93
|
-
"reconnect_only",
|
|
94
|
-
"actor_error",
|
|
95
|
-
error.message,
|
|
96
|
-
{ group: error.group, code: error.code },
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
85
|
if (
|
|
101
86
|
(error.group === "ups" && error.code === "consumer_closed") ||
|
|
102
87
|
(error.group === "depot" && error.code === "request_deadline_exceeded")
|
|
@@ -160,6 +160,58 @@ export interface SqliteTransactionDatabase {
|
|
|
160
160
|
rollback(): Promise<void>;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* A native database as `NativeDatabaseProvider.open` returns it. The synchronous calls and commit
|
|
165
|
+
* tickets work only when the database provider opts into deferred commits, which only embedders
|
|
166
|
+
* that hold output until writes are durable do. Internal: not exported from `rivetkit/db`.
|
|
167
|
+
*/
|
|
168
|
+
export interface DeferredSqliteDatabase extends SqliteDatabase {
|
|
169
|
+
/**
|
|
170
|
+
* Never waits behind other work. Fails with `sqlite.sync_unsupported` unless the actor uses
|
|
171
|
+
* deferred commits. Fails with the retryable `sqlite.writer_busy` while a transaction is open,
|
|
172
|
+
* including a state save, or while another call on this database is running, and with the
|
|
173
|
+
* retryable `sqlite.storage_overloaded` while too many earlier writes wait for storage.
|
|
174
|
+
*/
|
|
175
|
+
execSync(
|
|
176
|
+
sql: string,
|
|
177
|
+
callback?: (row: unknown[], columns: string[]) => void,
|
|
178
|
+
): void;
|
|
179
|
+
/** Fails like `execSync`. */
|
|
180
|
+
executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
181
|
+
/**
|
|
182
|
+
* Fails like `execSync`, also while a transaction is beginning or a manual `BEGIN` is open.
|
|
183
|
+
*/
|
|
184
|
+
beginTransactionSync(
|
|
185
|
+
timeoutMs?: number,
|
|
186
|
+
name?: string,
|
|
187
|
+
): SynchronousSqliteTransactionDatabase;
|
|
188
|
+
/**
|
|
189
|
+
* Returns the ticket of the latest local commit. Synchronous writes return before they are
|
|
190
|
+
* durable; pass the ticket to `whenDurable` before releasing output that depends on them.
|
|
191
|
+
*/
|
|
192
|
+
commitTicket(): number;
|
|
193
|
+
/**
|
|
194
|
+
* Resolves once the commit `ticket` names and every earlier commit are durable. Rejects with
|
|
195
|
+
* `sqlite.durability_failed` once the database broke and the actor is restarting.
|
|
196
|
+
*/
|
|
197
|
+
whenDurable(ticket: number): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Restarts the owning actor from durable state. Every later write fails, including the final
|
|
200
|
+
* state save. For native database providers whose in-memory state can no longer be trusted.
|
|
201
|
+
*/
|
|
202
|
+
abortGeneration(reason: string): void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type SynchronousSqliteTransactionDatabase = SqliteTransactionDatabase & {
|
|
206
|
+
execSync(
|
|
207
|
+
sql: string,
|
|
208
|
+
callback?: (row: unknown[], columns: string[]) => void,
|
|
209
|
+
): void;
|
|
210
|
+
executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult;
|
|
211
|
+
commitSync(): void;
|
|
212
|
+
rollbackSync(): void;
|
|
213
|
+
};
|
|
214
|
+
|
|
163
215
|
/**
|
|
164
216
|
* Provider for opening native databases from the active runtime.
|
|
165
217
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { decodeBridgeRivetError } from "@/actor/errors";
|
|
2
2
|
import type {
|
|
3
|
+
DeferredSqliteDatabase,
|
|
3
4
|
SqliteBatchStatement,
|
|
4
5
|
SqliteBindings,
|
|
5
|
-
SqliteDatabase,
|
|
6
6
|
SqliteExecuteResult,
|
|
7
7
|
SqliteNativeMetrics,
|
|
8
8
|
SqliteTransactionDatabase,
|
|
9
|
+
SynchronousSqliteTransactionDatabase,
|
|
9
10
|
} from "./config";
|
|
10
11
|
|
|
11
12
|
// Matches the name core uses for the transaction behind a native executeBatch call.
|
|
@@ -77,10 +78,15 @@ interface NativeBatchStatement {
|
|
|
77
78
|
|
|
78
79
|
export interface JsNativeDatabaseLike {
|
|
79
80
|
exec(sql: string): Promise<NativeExecResult>;
|
|
81
|
+
execSync(sql: string): NativeExecResult;
|
|
80
82
|
execute(
|
|
81
83
|
sql: string,
|
|
82
84
|
params?: NativeBindParam[] | null,
|
|
83
85
|
): Promise<NativeExecuteResult>;
|
|
86
|
+
executeSync(
|
|
87
|
+
sql: string,
|
|
88
|
+
params?: NativeBindParam[] | null,
|
|
89
|
+
): NativeExecuteResult;
|
|
84
90
|
executeBatch?(
|
|
85
91
|
statements: NativeBatchStatement[],
|
|
86
92
|
): Promise<NativeExecuteResult[]>;
|
|
@@ -93,6 +99,10 @@ export interface JsNativeDatabaseLike {
|
|
|
93
99
|
timeoutMs?: number,
|
|
94
100
|
name?: string,
|
|
95
101
|
): Promise<JsNativeTransactionLike>;
|
|
102
|
+
beginTransactionSync(
|
|
103
|
+
timeoutMs?: number,
|
|
104
|
+
name?: string,
|
|
105
|
+
): JsNativeSynchronousTransactionLike;
|
|
96
106
|
query(
|
|
97
107
|
sql: string,
|
|
98
108
|
params?: NativeBindParam[] | null,
|
|
@@ -103,9 +113,14 @@ export interface JsNativeDatabaseLike {
|
|
|
103
113
|
): Promise<NativeRunResult>;
|
|
104
114
|
metrics?(): SqliteNativeMetrics | null;
|
|
105
115
|
takeLastKvError?(): string | null;
|
|
116
|
+
open(): Promise<void>;
|
|
117
|
+
commitTicket(): number;
|
|
118
|
+
whenDurable(ticket: number): Promise<void>;
|
|
119
|
+
abortGeneration(reason: string): void;
|
|
106
120
|
close(): Promise<void>;
|
|
107
121
|
}
|
|
108
|
-
export type StateAwareSqliteDatabase =
|
|
122
|
+
export type StateAwareSqliteDatabase = DeferredSqliteDatabase & {
|
|
123
|
+
open(): Promise<void>;
|
|
109
124
|
beginStateTransaction(
|
|
110
125
|
timeoutMs?: number,
|
|
111
126
|
context?: unknown,
|
|
@@ -128,6 +143,28 @@ export interface JsNativeTransactionLike {
|
|
|
128
143
|
rollback(): Promise<void>;
|
|
129
144
|
}
|
|
130
145
|
|
|
146
|
+
export interface JsNativeSynchronousTransactionLike
|
|
147
|
+
extends JsNativeTransactionLike {
|
|
148
|
+
execSync(sql: string): NativeExecResult;
|
|
149
|
+
executeSync(
|
|
150
|
+
sql: string,
|
|
151
|
+
params?: NativeBindParam[] | null,
|
|
152
|
+
): NativeExecuteResult;
|
|
153
|
+
commitSync(): void;
|
|
154
|
+
rollbackSync(): void;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function isSynchronousTransaction(
|
|
158
|
+
transaction: JsNativeTransactionLike,
|
|
159
|
+
): transaction is JsNativeSynchronousTransactionLike {
|
|
160
|
+
const candidate =
|
|
161
|
+
transaction as Partial<JsNativeSynchronousTransactionLike>;
|
|
162
|
+
return (
|
|
163
|
+
typeof candidate.commitSync === "function" &&
|
|
164
|
+
typeof candidate.rollbackSync === "function"
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
131
168
|
function shouldAttachNativeKvError(message: string): boolean {
|
|
132
169
|
return /i\/o error|unable to open database file/i.test(message);
|
|
133
170
|
}
|
|
@@ -167,6 +204,16 @@ function toNativeBinding(arg: unknown): NativeBindParam {
|
|
|
167
204
|
return { kind: "null" };
|
|
168
205
|
}
|
|
169
206
|
if (typeof arg === "bigint") {
|
|
207
|
+
// Integers cross to native code as JavaScript numbers, which round a bigint past the
|
|
208
|
+
// safe range. Refuse instead of writing a different value.
|
|
209
|
+
if (
|
|
210
|
+
arg > BigInt(Number.MAX_SAFE_INTEGER) ||
|
|
211
|
+
arg < BigInt(Number.MIN_SAFE_INTEGER)
|
|
212
|
+
) {
|
|
213
|
+
throw new RangeError(
|
|
214
|
+
"SQLite bigint bindings must be within the JavaScript safe integer range.",
|
|
215
|
+
);
|
|
216
|
+
}
|
|
170
217
|
return { kind: "int", intValue: Number(arg) };
|
|
171
218
|
}
|
|
172
219
|
if (typeof arg === "number") {
|
|
@@ -190,9 +237,13 @@ function toNativeBinding(arg: unknown): NativeBindParam {
|
|
|
190
237
|
function extractNamedSqliteParameters(sql: string): string[] {
|
|
191
238
|
const orderedNames: string[] = [];
|
|
192
239
|
const seen = new Set<string>();
|
|
193
|
-
|
|
240
|
+
// SQLite identifiers may contain "$" and any non-ASCII character. Consume
|
|
241
|
+
// whole identifiers so their suffixes cannot be mistaken for parameters.
|
|
242
|
+
const pattern =
|
|
243
|
+
/'(?:''|[^'])*'|"(?:""|[^"])*"|`(?:``|[^`])*`|\[[^\]]*\]|--[^\n]*|\/\*[\s\S]*?(?:\*\/|$)|([:@$][\w$\u0080-\u{10FFFF}]+(?:::[\w$\u0080-\u{10FFFF}]+)*(?:\([^)]*\))?)|[A-Za-z_\u0080-\u{10FFFF}][\w$\u0080-\u{10FFFF}]*/gu;
|
|
194
244
|
for (const match of sql.matchAll(pattern)) {
|
|
195
245
|
const name = match[1];
|
|
246
|
+
if (!name) continue;
|
|
196
247
|
if (seen.has(name)) {
|
|
197
248
|
continue;
|
|
198
249
|
}
|
|
@@ -346,21 +397,49 @@ export function wrapJsNativeDatabase(
|
|
|
346
397
|
sql: string,
|
|
347
398
|
params?: SqliteBindings,
|
|
348
399
|
): Promise<SqliteExecuteResult> => {
|
|
349
|
-
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
350
|
-
if (lastInsertRowIdColumn) {
|
|
351
|
-
return {
|
|
352
|
-
columns: [lastInsertRowIdColumn],
|
|
353
|
-
rows: [[lastInsertRowId ?? 0]],
|
|
354
|
-
changes: 0,
|
|
355
|
-
lastInsertRowId,
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
400
|
const release = gate.enter();
|
|
360
401
|
try {
|
|
402
|
+
const lastInsertRowIdColumn = lastInsertRowIdColumnName(sql);
|
|
403
|
+
if (lastInsertRowIdColumn) {
|
|
404
|
+
return {
|
|
405
|
+
columns: [lastInsertRowIdColumn],
|
|
406
|
+
rows: [[lastInsertRowId ?? 0]],
|
|
407
|
+
changes: 0,
|
|
408
|
+
lastInsertRowId,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
361
412
|
const nativeParams = toNativeBindings(sql, params);
|
|
362
413
|
const result = await database.execute(sql, nativeParams);
|
|
363
|
-
if (result.lastInsertRowId
|
|
414
|
+
if (result.lastInsertRowId != null) {
|
|
415
|
+
lastInsertRowId = result.lastInsertRowId;
|
|
416
|
+
}
|
|
417
|
+
return result;
|
|
418
|
+
} catch (error) {
|
|
419
|
+
enrichNativeDatabaseError(database, error);
|
|
420
|
+
} finally {
|
|
421
|
+
release();
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
const executeNativeSync = (
|
|
425
|
+
sql: string,
|
|
426
|
+
params?: SqliteBindings,
|
|
427
|
+
): SqliteExecuteResult => {
|
|
428
|
+
const release = gate.enter();
|
|
429
|
+
try {
|
|
430
|
+
const nativeParams = toNativeBindings(sql, params);
|
|
431
|
+
const result = database.executeSync(sql, nativeParams);
|
|
432
|
+
// Execute first so runtime availability and transaction admission are enforced.
|
|
433
|
+
const rowIdColumn = lastInsertRowIdColumnName(sql);
|
|
434
|
+
if (rowIdColumn) {
|
|
435
|
+
return {
|
|
436
|
+
columns: [rowIdColumn],
|
|
437
|
+
rows: [[lastInsertRowId ?? 0]],
|
|
438
|
+
changes: 0,
|
|
439
|
+
lastInsertRowId,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
if (result.lastInsertRowId != null) {
|
|
364
443
|
lastInsertRowId = result.lastInsertRowId;
|
|
365
444
|
}
|
|
366
445
|
return result;
|
|
@@ -392,12 +471,34 @@ export function wrapJsNativeDatabase(
|
|
|
392
471
|
callback(row, result.columns);
|
|
393
472
|
}
|
|
394
473
|
},
|
|
474
|
+
execSync(
|
|
475
|
+
sql: string,
|
|
476
|
+
callback?: (row: unknown[], columns: string[]) => void,
|
|
477
|
+
): void {
|
|
478
|
+
const release = gate.enter();
|
|
479
|
+
let result: NativeExecResult;
|
|
480
|
+
try {
|
|
481
|
+
result = database.execSync(sql);
|
|
482
|
+
} catch (error) {
|
|
483
|
+
enrichNativeDatabaseError(database, error);
|
|
484
|
+
} finally {
|
|
485
|
+
release();
|
|
486
|
+
}
|
|
487
|
+
if (callback) {
|
|
488
|
+
for (const row of result.rows) {
|
|
489
|
+
callback(row, result.columns);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
},
|
|
395
493
|
async execute(
|
|
396
494
|
sql: string,
|
|
397
495
|
params?: SqliteBindings,
|
|
398
496
|
): Promise<SqliteExecuteResult> {
|
|
399
497
|
return await executeNative(sql, params);
|
|
400
498
|
},
|
|
499
|
+
executeSync(sql: string, params?: SqliteBindings): SqliteExecuteResult {
|
|
500
|
+
return executeNativeSync(sql, params);
|
|
501
|
+
},
|
|
401
502
|
async executeBatch(
|
|
402
503
|
statements: SqliteBatchStatement[],
|
|
403
504
|
): Promise<SqliteExecuteResult[]> {
|
|
@@ -427,7 +528,7 @@ export function wrapJsNativeDatabase(
|
|
|
427
528
|
return transactionResults;
|
|
428
529
|
})();
|
|
429
530
|
for (const result of results) {
|
|
430
|
-
if (result.lastInsertRowId
|
|
531
|
+
if (result.lastInsertRowId != null) {
|
|
431
532
|
lastInsertRowId = result.lastInsertRowId;
|
|
432
533
|
}
|
|
433
534
|
}
|
|
@@ -459,7 +560,26 @@ export function wrapJsNativeDatabase(
|
|
|
459
560
|
release();
|
|
460
561
|
}
|
|
461
562
|
return wrapTransaction(database, transaction, gate, (result) => {
|
|
462
|
-
if (result.lastInsertRowId
|
|
563
|
+
if (result.lastInsertRowId != null) {
|
|
564
|
+
lastInsertRowId = result.lastInsertRowId;
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
},
|
|
568
|
+
beginTransactionSync(
|
|
569
|
+
timeoutMs?: number,
|
|
570
|
+
name?: string,
|
|
571
|
+
): SynchronousSqliteTransactionDatabase {
|
|
572
|
+
const release = gate.enter();
|
|
573
|
+
let transaction: JsNativeSynchronousTransactionLike;
|
|
574
|
+
try {
|
|
575
|
+
transaction = database.beginTransactionSync(timeoutMs, name);
|
|
576
|
+
} catch (error) {
|
|
577
|
+
enrichNativeDatabaseError(database, error);
|
|
578
|
+
} finally {
|
|
579
|
+
release();
|
|
580
|
+
}
|
|
581
|
+
return wrapTransaction(database, transaction, gate, (result) => {
|
|
582
|
+
if (result.lastInsertRowId != null) {
|
|
463
583
|
lastInsertRowId = result.lastInsertRowId;
|
|
464
584
|
}
|
|
465
585
|
});
|
|
@@ -486,7 +606,7 @@ export function wrapJsNativeDatabase(
|
|
|
486
606
|
release();
|
|
487
607
|
}
|
|
488
608
|
return wrapTransaction(database, transaction, gate, (result) => {
|
|
489
|
-
if (result.lastInsertRowId
|
|
609
|
+
if (result.lastInsertRowId != null) {
|
|
490
610
|
lastInsertRowId = result.lastInsertRowId;
|
|
491
611
|
}
|
|
492
612
|
});
|
|
@@ -501,6 +621,25 @@ export function wrapJsNativeDatabase(
|
|
|
501
621
|
nativeMetrics(): SqliteNativeMetrics | null {
|
|
502
622
|
return normalizeNativeMetrics(database.metrics?.());
|
|
503
623
|
},
|
|
624
|
+
async open(): Promise<void> {
|
|
625
|
+
const release = gate.enter();
|
|
626
|
+
try {
|
|
627
|
+
await database.open();
|
|
628
|
+
} catch (error) {
|
|
629
|
+
enrichNativeDatabaseError(database, error);
|
|
630
|
+
} finally {
|
|
631
|
+
release();
|
|
632
|
+
}
|
|
633
|
+
},
|
|
634
|
+
commitTicket(): number {
|
|
635
|
+
return database.commitTicket();
|
|
636
|
+
},
|
|
637
|
+
async whenDurable(ticket: number): Promise<void> {
|
|
638
|
+
await database.whenDurable(ticket);
|
|
639
|
+
},
|
|
640
|
+
abortGeneration(reason: string): void {
|
|
641
|
+
database.abortGeneration(reason);
|
|
642
|
+
},
|
|
504
643
|
async close(): Promise<void> {
|
|
505
644
|
terminalPromise ??= gate.close(() => database.close());
|
|
506
645
|
await terminalPromise;
|
|
@@ -512,13 +651,25 @@ export function wrapJsNativeDatabase(
|
|
|
512
651
|
};
|
|
513
652
|
}
|
|
514
653
|
|
|
654
|
+
function wrapTransaction(
|
|
655
|
+
database: JsNativeDatabaseLike,
|
|
656
|
+
transaction: JsNativeSynchronousTransactionLike,
|
|
657
|
+
gate: NativeCloseGate,
|
|
658
|
+
onExecute: (result: NativeExecuteResult) => void,
|
|
659
|
+
): SynchronousSqliteTransactionDatabase;
|
|
660
|
+
function wrapTransaction(
|
|
661
|
+
database: JsNativeDatabaseLike,
|
|
662
|
+
transaction: JsNativeTransactionLike,
|
|
663
|
+
gate: NativeCloseGate,
|
|
664
|
+
onExecute: (result: NativeExecuteResult) => void,
|
|
665
|
+
): SqliteTransactionDatabase;
|
|
515
666
|
function wrapTransaction(
|
|
516
667
|
database: JsNativeDatabaseLike,
|
|
517
668
|
transaction: JsNativeTransactionLike,
|
|
518
669
|
gate: NativeCloseGate,
|
|
519
670
|
onExecute: (result: NativeExecuteResult) => void,
|
|
520
671
|
): SqliteTransactionDatabase {
|
|
521
|
-
|
|
672
|
+
const wrapped: SqliteTransactionDatabase = {
|
|
522
673
|
async exec(sql, callback) {
|
|
523
674
|
const release = gate.enter();
|
|
524
675
|
let result: NativeExecResult;
|
|
@@ -569,6 +720,66 @@ function wrapTransaction(
|
|
|
569
720
|
}
|
|
570
721
|
},
|
|
571
722
|
};
|
|
723
|
+
|
|
724
|
+
if (isSynchronousTransaction(transaction)) {
|
|
725
|
+
return Object.assign(wrapped, {
|
|
726
|
+
execSync(
|
|
727
|
+
sql: string,
|
|
728
|
+
callback?: (row: unknown[], columns: string[]) => void,
|
|
729
|
+
) {
|
|
730
|
+
const release = gate.enter();
|
|
731
|
+
let result: NativeExecResult;
|
|
732
|
+
try {
|
|
733
|
+
result = transaction.execSync(sql);
|
|
734
|
+
} catch (error) {
|
|
735
|
+
enrichNativeDatabaseError(database, error);
|
|
736
|
+
} finally {
|
|
737
|
+
release();
|
|
738
|
+
}
|
|
739
|
+
if (callback) {
|
|
740
|
+
for (const row of result.rows)
|
|
741
|
+
callback(row, result.columns);
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
executeSync(sql: string, params?: SqliteBindings) {
|
|
745
|
+
const release = gate.enter();
|
|
746
|
+
try {
|
|
747
|
+
const result = transaction.executeSync(
|
|
748
|
+
sql,
|
|
749
|
+
toNativeBindings(sql, params),
|
|
750
|
+
);
|
|
751
|
+
onExecute(result);
|
|
752
|
+
return result;
|
|
753
|
+
} catch (error) {
|
|
754
|
+
enrichNativeDatabaseError(database, error);
|
|
755
|
+
} finally {
|
|
756
|
+
release();
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
commitSync() {
|
|
760
|
+
const release = gate.enter();
|
|
761
|
+
try {
|
|
762
|
+
transaction.commitSync();
|
|
763
|
+
} catch (error) {
|
|
764
|
+
enrichNativeDatabaseError(database, error);
|
|
765
|
+
} finally {
|
|
766
|
+
release();
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
rollbackSync() {
|
|
770
|
+
const release = gate.enter();
|
|
771
|
+
try {
|
|
772
|
+
transaction.rollbackSync();
|
|
773
|
+
} catch (error) {
|
|
774
|
+
enrichNativeDatabaseError(database, error);
|
|
775
|
+
} finally {
|
|
776
|
+
release();
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
}) as SynchronousSqliteTransactionDatabase;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
return wrapped;
|
|
572
783
|
}
|
|
573
784
|
|
|
574
785
|
function lastInsertRowIdColumnName(sql: string): string | undefined {
|