rivetkit 2.3.9 → 2.3.11-rc.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 +2 -12
- package/dist/browser/client.js +22 -27
- 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/agent-os/index.cjs +1 -1
- package/dist/tsup/agent-os/index.cjs.map +1 -1
- package/dist/tsup/agent-os/index.d.cts +2 -12
- package/dist/tsup/agent-os/index.d.ts +2 -12
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-S57DMBTM.cjs → chunk-57ZE43T5.cjs} +3 -3
- package/dist/tsup/{chunk-S57DMBTM.cjs.map → chunk-57ZE43T5.cjs.map} +1 -1
- package/dist/tsup/{chunk-X25YYVFL.js → chunk-5FVMFSBH.js} +2 -2
- package/dist/tsup/{chunk-BQU4XTKM.js → chunk-5ZS22TOP.js} +3 -3
- package/dist/tsup/{chunk-CQ23UFQ4.js → chunk-6ZPMYIZ6.js} +2 -2
- package/dist/tsup/{chunk-UBYPRYJR.js → chunk-ET2F6BXK.js} +2 -2
- package/dist/tsup/chunk-ET2F6BXK.js.map +1 -0
- package/dist/tsup/{chunk-AVUMOGUE.cjs → chunk-JAQHV6LB.cjs} +7 -7
- package/dist/tsup/{chunk-AVUMOGUE.cjs.map → chunk-JAQHV6LB.cjs.map} +1 -1
- package/dist/tsup/{chunk-GZ5DYSIR.cjs → chunk-K4DNAIWT.cjs} +4 -4
- package/dist/tsup/{chunk-GZ5DYSIR.cjs.map → chunk-K4DNAIWT.cjs.map} +1 -1
- package/dist/tsup/{chunk-KVKWTOW7.js → chunk-L4DYLD7P.js} +3 -3
- package/dist/tsup/{chunk-MQDQ3A72.js → chunk-MMPE77KO.js} +27 -33
- package/dist/tsup/chunk-MMPE77KO.js.map +1 -0
- package/dist/tsup/{chunk-M4R2O5NJ.cjs → chunk-TWNMQDZK.cjs} +2 -2
- package/dist/tsup/chunk-TWNMQDZK.cjs.map +1 -0
- package/dist/tsup/{chunk-3IDKUXQT.cjs → chunk-W2YEXCCJ.cjs} +163 -169
- package/dist/tsup/chunk-W2YEXCCJ.cjs.map +1 -0
- package/dist/tsup/{chunk-KPP2YRS5.cjs → chunk-XEOPXHN2.cjs} +9 -9
- package/dist/tsup/{chunk-KPP2YRS5.cjs.map → chunk-XEOPXHN2.cjs.map} +1 -1
- 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-CUymbyM6.d.ts → config-BKAMOHez.d.ts} +2 -12
- package/dist/tsup/{config-CpB-e4I9.d.cts → config-Caocy3Z9.d.cts} +2 -12
- package/dist/tsup/{context-YBUBTwTS.d.ts → context-AfCExwbr.d.ts} +1 -1
- package/dist/tsup/{context-c-6G4mjk.d.cts → context-D1_m5x1D.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 +2 -2
- package/dist/tsup/db/mod.js +1 -1
- package/dist/tsup/dynamic/mod.d.cts +1 -1
- package/dist/tsup/dynamic/mod.d.ts +1 -1
- package/dist/tsup/inspector/mod.cjs +4 -4
- package/dist/tsup/inspector/mod.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 +131 -341
- 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 +68 -278
- 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 +6 -6
- package/dist/tsup/workflow/mod.d.cts +3 -3
- package/dist/tsup/workflow/mod.d.ts +3 -3
- package/dist/tsup/workflow/mod.js +3 -3
- package/package.json +8 -8
- package/src/client/actor-handle.ts +1 -3
- package/src/client/raw-utils.ts +0 -8
- package/src/common/actor-router-consts.ts +0 -1
- package/src/engine-client/actor-http-client.ts +22 -6
- package/src/registry/index.ts +11 -51
- package/src/registry/napi-runtime.ts +5 -32
- package/src/registry/native.ts +63 -110
- package/src/registry/runtime.ts +2 -16
- package/dist/tsup/chunk-3IDKUXQT.cjs.map +0 -1
- package/dist/tsup/chunk-M4R2O5NJ.cjs.map +0 -1
- package/dist/tsup/chunk-MQDQ3A72.js.map +0 -1
- package/dist/tsup/chunk-UBYPRYJR.js.map +0 -1
- package/src/registry/native-http.ts +0 -208
- /package/dist/tsup/{chunk-X25YYVFL.js.map → chunk-5FVMFSBH.js.map} +0 -0
- /package/dist/tsup/{chunk-BQU4XTKM.js.map → chunk-5ZS22TOP.js.map} +0 -0
- /package/dist/tsup/{chunk-CQ23UFQ4.js.map → chunk-6ZPMYIZ6.js.map} +0 -0
- /package/dist/tsup/{chunk-KVKWTOW7.js.map → chunk-L4DYLD7P.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 _chunkJAQHV6LBcjs = require('../chunk-JAQHV6LB.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkW2YEXCCJcjs = require('../chunk-W2YEXCCJ.cjs');
|
|
7
7
|
require('../chunk-MYWZCDML.cjs');
|
|
8
8
|
require('../chunk-UEULFXUI.cjs');
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
9
|
+
require('../chunk-57ZE43T5.cjs');
|
|
10
|
+
require('../chunk-TWNMQDZK.cjs');
|
|
11
11
|
require('../chunk-4FC7TVS6.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 = _chunkJAQHV6LBcjs.createClient.call(void 0, {
|
|
40
|
+
..._chunkW2YEXCCJcjs.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 { aC as Registry, a2 as Client } from '../config-
|
|
2
|
+
import { aC as Registry, a2 as Client } from '../config-Caocy3Z9.cjs';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '../config-BxOimoGX.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 { aC as Registry, a2 as Client } from '../config-
|
|
2
|
+
import { aC as Registry, a2 as Client } from '../config-BKAMOHez.js';
|
|
3
3
|
import 'zod/v4';
|
|
4
4
|
import '../config-BxOimoGX.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-L4DYLD7P.js";
|
|
4
4
|
import {
|
|
5
5
|
convertRegistryConfigToClientConfig
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-MMPE77KO.js";
|
|
7
7
|
import "../chunk-JI6GZ2C2.js";
|
|
8
8
|
import "../chunk-7AFZMFPQ.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-5FVMFSBH.js";
|
|
10
|
+
import "../chunk-ET2F6BXK.js";
|
|
11
11
|
import "../chunk-ZZ3WBRPD.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 _chunkTWNMQDZKcjs = require('./chunk-TWNMQDZK.cjs');
|
|
23
23
|
require('./chunk-4FC7TVS6.cjs');
|
|
24
24
|
|
|
25
25
|
|
|
@@ -42,5 +42,5 @@ require('./chunk-4FC7TVS6.cjs');
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.EXTRA_ERROR_LOG =
|
|
45
|
+
exports.EXTRA_ERROR_LOG = _chunkTWNMQDZKcjs.EXTRA_ERROR_LOG; exports.SinglePromiseQueue = _chunkTWNMQDZKcjs.SinglePromiseQueue; exports.VERSION = _chunkTWNMQDZKcjs.VERSION; exports.arrayBuffersEqual = _chunkTWNMQDZKcjs.arrayBuffersEqual; exports.assertUnreachable = _chunkTWNMQDZKcjs.assertUnreachable; exports.bufferToArrayBuffer = _chunkTWNMQDZKcjs.bufferToArrayBuffer; exports.combineUrlPath = _chunkTWNMQDZKcjs.combineUrlPath; exports.dbg = _chunkTWNMQDZKcjs.dbg; exports.detectRuntime = _chunkTWNMQDZKcjs.detectRuntime; exports.getEnvUniversal = _chunkTWNMQDZKcjs.getEnvUniversal; exports.httpUserAgent = _chunkTWNMQDZKcjs.httpUserAgent; exports.interval = _chunkTWNMQDZKcjs.interval; exports.joinSignals = _chunkTWNMQDZKcjs.joinSignals; exports.jsonParseCompat = _chunkTWNMQDZKcjs.jsonParseCompat; exports.jsonStringifyCompat = _chunkTWNMQDZKcjs.jsonStringifyCompat; exports.promiseWithResolvers = _chunkTWNMQDZKcjs.promiseWithResolvers; exports.setLongTimeout = _chunkTWNMQDZKcjs.setLongTimeout; exports.sleep = _chunkTWNMQDZKcjs.sleep; exports.stringifyError = _chunkTWNMQDZKcjs.stringifyError; exports.toUint8Array = _chunkTWNMQDZKcjs.toUint8Array;
|
|
46
46
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/tsup/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
3
|
+
var _chunkXEOPXHN2cjs = require('../chunk-XEOPXHN2.cjs');
|
|
4
|
+
require('../chunk-K4DNAIWT.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ var _chunkHNHLBM3Ycjs = require('../chunk-HNHLBM3Y.cjs');
|
|
|
12
12
|
var _chunkMYWZCDMLcjs = require('../chunk-MYWZCDML.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkTWNMQDZKcjs = require('../chunk-TWNMQDZK.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -716,7 +716,7 @@ function workflow(fn, options = {}) {
|
|
|
716
716
|
function getWorkflowInspector(actorId) {
|
|
717
717
|
let workflowInspector = workflowInspectors.get(actorId);
|
|
718
718
|
if (!workflowInspector) {
|
|
719
|
-
workflowInspector =
|
|
719
|
+
workflowInspector = _chunkXEOPXHN2cjs.createWorkflowInspectorAdapter.call(void 0, );
|
|
720
720
|
workflowInspectors.set(actorId, workflowInspector);
|
|
721
721
|
}
|
|
722
722
|
return workflowInspector;
|
|
@@ -784,13 +784,13 @@ function workflow(fn, options = {}) {
|
|
|
784
784
|
if (shouldRethrowWorkflowError(error)) {
|
|
785
785
|
runCtx.log.error({
|
|
786
786
|
msg: "workflow run failed",
|
|
787
|
-
error:
|
|
787
|
+
error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, error)
|
|
788
788
|
});
|
|
789
789
|
throw error;
|
|
790
790
|
}
|
|
791
791
|
runCtx.log.warn({
|
|
792
792
|
msg: "workflow failed and will sleep until woken",
|
|
793
|
-
error:
|
|
793
|
+
error: _chunkTWNMQDZKcjs.stringifyError.call(void 0, error)
|
|
794
794
|
});
|
|
795
795
|
} finally {
|
|
796
796
|
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-Caocy3Z9.cjs';
|
|
4
4
|
import { A as AnyDatabaseProvider } from '../config-BxOimoGX.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-D1_m5x1D.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-D1_m5x1D.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-BKAMOHez.js';
|
|
4
4
|
import { A as AnyDatabaseProvider } from '../config-BxOimoGX.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-AfCExwbr.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-AfCExwbr.js';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@rivetkit/rivetkit-wasm';
|
|
9
9
|
import 'zod';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createWorkflowInspectorAdapter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-5ZS22TOP.js";
|
|
4
|
+
import "../chunk-6ZPMYIZ6.js";
|
|
5
5
|
import {
|
|
6
6
|
ACTOR_CONTEXT_INTERNAL_SYMBOL,
|
|
7
7
|
RUN_FUNCTION_CONFIG_SYMBOL
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../chunk-JI6GZ2C2.js";
|
|
13
13
|
import {
|
|
14
14
|
stringifyError
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-ET2F6BXK.js";
|
|
16
16
|
import {
|
|
17
17
|
RivetError,
|
|
18
18
|
isActorAbortedError
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rivetkit",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.11-rc.1",
|
|
4
4
|
"description": "Lightweight libraries for building stateful actors on edge platforms",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -201,14 +201,14 @@
|
|
|
201
201
|
"@hono/zod-openapi": "^1.1.5",
|
|
202
202
|
"@rivet-dev/agent-os-core": "^0.1.1",
|
|
203
203
|
"@rivetkit/bare-ts": "^0.6.2",
|
|
204
|
-
"@rivetkit/engine-cli": "2.3.
|
|
205
|
-
"@rivetkit/engine-envoy-protocol": "2.3.
|
|
204
|
+
"@rivetkit/engine-cli": "2.3.11-rc.1",
|
|
205
|
+
"@rivetkit/engine-envoy-protocol": "2.3.11-rc.1",
|
|
206
206
|
"@rivetkit/on-change": "6.0.1",
|
|
207
|
-
"@rivetkit/rivetkit-napi": "2.3.
|
|
208
|
-
"@rivetkit/rivetkit-wasm": "2.3.
|
|
209
|
-
"@rivetkit/traces": "2.3.
|
|
210
|
-
"@rivetkit/virtual-websocket": "2.3.
|
|
211
|
-
"@rivetkit/workflow-engine": "2.3.
|
|
207
|
+
"@rivetkit/rivetkit-napi": "2.3.11-rc.1",
|
|
208
|
+
"@rivetkit/rivetkit-wasm": "2.3.11-rc.1",
|
|
209
|
+
"@rivetkit/traces": "2.3.11-rc.1",
|
|
210
|
+
"@rivetkit/virtual-websocket": "2.3.11-rc.1",
|
|
211
|
+
"@rivetkit/workflow-engine": "2.3.11-rc.1",
|
|
212
212
|
"cbor-x": "^1.6.0",
|
|
213
213
|
"drizzle-orm": "^0.44.2",
|
|
214
214
|
"hono": "^4.7.0",
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
HEADER_CONN_PARAMS,
|
|
5
5
|
HEADER_ENCODING,
|
|
6
6
|
} from "@/common/actor-router-consts";
|
|
7
|
-
import { isRequestLike } from "@/common/fetch-like";
|
|
8
7
|
import type * as protocol from "@/common/client-protocol";
|
|
9
8
|
import {
|
|
10
9
|
CURRENT_VERSION as CLIENT_PROTOCOL_CURRENT_VERSION,
|
|
@@ -641,7 +640,6 @@ export class ActorHandleRaw {
|
|
|
641
640
|
) {
|
|
642
641
|
const maxAttempts = this.#getDynamicQueryMaxAttempts();
|
|
643
642
|
let useQueryTarget = false;
|
|
644
|
-
const retryableRequest = isRequestLike(input) ? input.clone() : undefined;
|
|
645
643
|
const { skipReadyWait, ...requestInit } = init ?? {};
|
|
646
644
|
const gatewayOptions = resolveActorGatewayOptions(
|
|
647
645
|
this.#gatewayOptions,
|
|
@@ -662,7 +660,7 @@ export class ActorHandleRaw {
|
|
|
662
660
|
this.#driver,
|
|
663
661
|
target,
|
|
664
662
|
this.#params,
|
|
665
|
-
|
|
663
|
+
input,
|
|
666
664
|
requestInit,
|
|
667
665
|
gatewayOptions,
|
|
668
666
|
);
|
package/src/client/raw-utils.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HEADER_CONN_PARAMS,
|
|
3
|
-
HEADER_ORIGINAL_REQUEST_URL,
|
|
4
3
|
PATH_WEBSOCKET_PREFIX,
|
|
5
4
|
} from "@/common/actor-router-consts";
|
|
6
5
|
import { deconstructError } from "@/common/utils";
|
|
@@ -26,19 +25,16 @@ export async function rawHttpFetch(
|
|
|
26
25
|
): Promise<Response> {
|
|
27
26
|
// Extract path and merge init options
|
|
28
27
|
let path: string;
|
|
29
|
-
let originalUrl: string | undefined;
|
|
30
28
|
let mergedInit: RequestInit = init || {};
|
|
31
29
|
|
|
32
30
|
if (typeof input === "string") {
|
|
33
31
|
path = input;
|
|
34
32
|
} else if (isUrlLike(input)) {
|
|
35
33
|
path = input.pathname + input.search;
|
|
36
|
-
originalUrl = input.toString();
|
|
37
34
|
} else if (isRequestLike(input)) {
|
|
38
35
|
// Extract path from Request URL
|
|
39
36
|
const url = new URL(input.url);
|
|
40
37
|
path = url.pathname + url.search;
|
|
41
|
-
originalUrl = url.toString();
|
|
42
38
|
// Merge Request properties with init
|
|
43
39
|
const requestHeaders = new Headers(input.headers);
|
|
44
40
|
const initHeaders = new Headers(init?.headers || {});
|
|
@@ -90,10 +86,6 @@ export async function rawHttpFetch(
|
|
|
90
86
|
|
|
91
87
|
// Forward conn params if provided
|
|
92
88
|
const proxyRequestHeaders = new Headers(mergedInit.headers);
|
|
93
|
-
proxyRequestHeaders.delete(HEADER_ORIGINAL_REQUEST_URL);
|
|
94
|
-
if (originalUrl) {
|
|
95
|
-
proxyRequestHeaders.set(HEADER_ORIGINAL_REQUEST_URL, originalUrl);
|
|
96
|
-
}
|
|
97
89
|
if (params) {
|
|
98
90
|
proxyRequestHeaders.set(HEADER_CONN_PARAMS, JSON.stringify(params));
|
|
99
91
|
}
|
|
@@ -12,7 +12,6 @@ export const HEADER_ENCODING = "x-rivet-encoding";
|
|
|
12
12
|
|
|
13
13
|
// IMPORTANT: Params must be in headers or in an E2EE part of the request (i.e. NOT the URL or query string) in order to ensure that tokens can be securely passed in params.
|
|
14
14
|
export const HEADER_CONN_PARAMS = "x-rivet-conn-params";
|
|
15
|
-
export const HEADER_ORIGINAL_REQUEST_URL = "x-rivet-internal-original-request-url";
|
|
16
15
|
|
|
17
16
|
export const HEADER_ACTOR_ID = "x-rivet-actor";
|
|
18
17
|
export const HEADER_ACTOR_GENERATION = "x-rivet-actor-generation";
|
|
@@ -17,7 +17,8 @@ export async function sendHttpRequestToGateway(
|
|
|
17
17
|
actorRequest: Request,
|
|
18
18
|
options: HttpGatewayRequestOptions = {},
|
|
19
19
|
): Promise<Response> {
|
|
20
|
-
|
|
20
|
+
// Handle body properly based on method and presence
|
|
21
|
+
let bodyToSend: ArrayBuffer | null = null;
|
|
21
22
|
const guardHeaders = buildGuardHeaders(runConfig, actorRequest, options);
|
|
22
23
|
|
|
23
24
|
if (actorRequest.method !== "GET" && actorRequest.method !== "HEAD") {
|
|
@@ -25,20 +26,35 @@ export async function sendHttpRequestToGateway(
|
|
|
25
26
|
throw new Error("Request body has already been consumed");
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
// TODO: This buffers the entire request in memory every time. We
|
|
30
|
+
// need to properly implement streaming bodies.
|
|
31
|
+
const reqBody = await actorRequest.arrayBuffer();
|
|
32
|
+
|
|
33
|
+
if (reqBody.byteLength !== 0) {
|
|
34
|
+
bodyToSend = reqBody;
|
|
35
|
+
|
|
36
|
+
// If this is a streaming request, we need to convert the headers
|
|
37
|
+
// for the basic array buffer.
|
|
30
38
|
guardHeaders.delete("transfer-encoding");
|
|
31
39
|
guardHeaders.delete("content-length");
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
const guardRequest = new Request(gatewayUrl, {
|
|
36
44
|
method: actorRequest.method,
|
|
37
45
|
headers: guardHeaders,
|
|
38
46
|
body: bodyToSend,
|
|
39
47
|
signal: actorRequest.signal,
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return mutableResponse(await fetch(guardRequest));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function mutableResponse(fetchRes: Response): Response {
|
|
54
|
+
// We cannot return the raw response from `fetch` since the response type is not mutable.
|
|
55
|
+
//
|
|
56
|
+
// In order for middleware to be able to mutate the response, we need to build a new Response object that is mutable.
|
|
57
|
+
return new Response(fetchRes.body, fetchRes);
|
|
42
58
|
}
|
|
43
59
|
|
|
44
60
|
function buildGuardHeaders(
|
package/src/registry/index.ts
CHANGED
|
@@ -15,14 +15,9 @@ import {
|
|
|
15
15
|
RegistryConfigSchema,
|
|
16
16
|
} from "./config";
|
|
17
17
|
import { logger } from "./log";
|
|
18
|
-
import {
|
|
19
|
-
buildConfiguredRegistry,
|
|
20
|
-
} from "./native";
|
|
21
|
-
import { convertNativeHttpResponse } from "./native-http";
|
|
18
|
+
import { buildConfiguredRegistry } from "./native";
|
|
22
19
|
import type {
|
|
23
|
-
CoreRuntime,
|
|
24
20
|
RuntimeApplicationFetch,
|
|
25
|
-
RuntimeHttpResponseBodyStream,
|
|
26
21
|
RuntimeServerlessResponseHead,
|
|
27
22
|
} from "./runtime";
|
|
28
23
|
|
|
@@ -48,34 +43,18 @@ function finishShutdownSignal(signal: ShutdownSignal): void {
|
|
|
48
43
|
|
|
49
44
|
function createApplicationFetch(
|
|
50
45
|
application: RegistryApplication,
|
|
51
|
-
runtime: CoreRuntime,
|
|
52
46
|
): RuntimeApplicationFetch {
|
|
53
|
-
return async (
|
|
54
|
-
request,
|
|
55
|
-
responseBodyStream?: RuntimeHttpResponseBodyStream,
|
|
56
|
-
) => {
|
|
47
|
+
return async (request) => {
|
|
57
48
|
const method = request.method.toUpperCase();
|
|
58
49
|
const body =
|
|
59
50
|
method === "GET" || method === "HEAD" || request.body.length === 0
|
|
60
51
|
? undefined
|
|
61
52
|
: Uint8Array.from(request.body).buffer;
|
|
62
|
-
const abortController = new AbortController();
|
|
63
|
-
if (request.cancelToken) {
|
|
64
|
-
if (runtime.cancellationTokenAborted(request.cancelToken)) {
|
|
65
|
-
abortController.abort();
|
|
66
|
-
} else {
|
|
67
|
-
runtime.onCancellationTokenCancelled(
|
|
68
|
-
request.cancelToken,
|
|
69
|
-
() => abortController.abort(),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
53
|
const response = await application.fetch(
|
|
74
54
|
new Request(request.url, {
|
|
75
55
|
method,
|
|
76
56
|
headers: request.headers,
|
|
77
57
|
body,
|
|
78
|
-
signal: abortController.signal,
|
|
79
58
|
}),
|
|
80
59
|
);
|
|
81
60
|
if (!isResponseLike(response)) {
|
|
@@ -83,25 +62,10 @@ function createApplicationFetch(
|
|
|
83
62
|
"registry.listen() application fetch must return a Response",
|
|
84
63
|
);
|
|
85
64
|
}
|
|
86
|
-
const conversion = await convertNativeHttpResponse(
|
|
87
|
-
response,
|
|
88
|
-
responseBodyStream,
|
|
89
|
-
);
|
|
90
|
-
if (conversion.bodyCompletion) {
|
|
91
|
-
void conversion.bodyCompletion.catch((error) => {
|
|
92
|
-
logger().error({
|
|
93
|
-
msg: "application response stream failed",
|
|
94
|
-
error,
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
65
|
return {
|
|
99
|
-
status:
|
|
100
|
-
headers:
|
|
101
|
-
|
|
102
|
-
Object.fromEntries(response.headers.entries()),
|
|
103
|
-
body: conversion.response.body,
|
|
104
|
-
stream: conversion.response.stream,
|
|
66
|
+
status: response.status,
|
|
67
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
68
|
+
body: new Uint8Array(await response.arrayBuffer()),
|
|
105
69
|
};
|
|
106
70
|
};
|
|
107
71
|
}
|
|
@@ -442,8 +406,11 @@ export class Registry<A extends RegistryActors> {
|
|
|
442
406
|
const port = opts.port ?? parsePortEnv(process.env.RIVET_PORT) ?? 3000;
|
|
443
407
|
const publicDir = opts.publicDir ?? getRivetkitPublicDir();
|
|
444
408
|
const config = this.parseConfig();
|
|
409
|
+
const application = opts.application
|
|
410
|
+
? createApplicationFetch(opts.application)
|
|
411
|
+
: undefined;
|
|
445
412
|
|
|
446
|
-
if (
|
|
413
|
+
if (application && getRivetkitRuntimeMode() !== "serverless") {
|
|
447
414
|
if (config.runtime === "wasm") {
|
|
448
415
|
throw new Error(
|
|
449
416
|
"registry.listen() requires the native runtime; use an application-owned HTTP server with WebAssembly",
|
|
@@ -464,11 +431,6 @@ export class Registry<A extends RegistryActors> {
|
|
|
464
431
|
}
|
|
465
432
|
const { runtime, registry, serveConfig } =
|
|
466
433
|
await configuredRegistryPromise;
|
|
467
|
-
const application = createApplicationFetch(
|
|
468
|
-
opts.application,
|
|
469
|
-
runtime,
|
|
470
|
-
);
|
|
471
|
-
await readyPromise;
|
|
472
434
|
const listenerPromise = runtime.serveApplicationListener(
|
|
473
435
|
registry,
|
|
474
436
|
{
|
|
@@ -487,6 +449,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
487
449
|
);
|
|
488
450
|
}
|
|
489
451
|
await Promise.all([
|
|
452
|
+
readyPromise,
|
|
490
453
|
listenerPromise,
|
|
491
454
|
serveLifecyclePromise,
|
|
492
455
|
]);
|
|
@@ -494,7 +457,7 @@ export class Registry<A extends RegistryActors> {
|
|
|
494
457
|
}
|
|
495
458
|
|
|
496
459
|
// Cache on both promise fields so the shutdown drain sees Mode A and B.
|
|
497
|
-
const configuredRegistryPromise =
|
|
460
|
+
const configuredRegistryPromise = buildConfiguredRegistry(config);
|
|
498
461
|
this.#runtimeServeConfiguredPromise = configuredRegistryPromise;
|
|
499
462
|
this.#runtimeServerlessPromise = configuredRegistryPromise;
|
|
500
463
|
this.#installSignalHandlers(config);
|
|
@@ -510,9 +473,6 @@ export class Registry<A extends RegistryActors> {
|
|
|
510
473
|
|
|
511
474
|
const { runtime, registry, serveConfig } =
|
|
512
475
|
await configuredRegistryPromise;
|
|
513
|
-
const application = opts.application
|
|
514
|
-
? createApplicationFetch(opts.application, runtime)
|
|
515
|
-
: undefined;
|
|
516
476
|
await runtime.serveListener(
|
|
517
477
|
registry,
|
|
518
478
|
{
|
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
CancellationToken as NativeCancellationToken,
|
|
5
5
|
ConnHandle as NativeConnHandle,
|
|
6
6
|
CoreRegistry as NativeCoreRegistry,
|
|
7
|
-
HttpResponseBodyStream as NativeHttpResponseBodyStream,
|
|
8
7
|
WebSocket as NativeWebSocket,
|
|
9
8
|
} from "@rivetkit/rivetkit-napi";
|
|
10
9
|
import type {
|
|
@@ -21,7 +20,6 @@ import type {
|
|
|
21
20
|
RuntimeCronFire,
|
|
22
21
|
RuntimeCronJobInfo,
|
|
23
22
|
RuntimeHttpRequest,
|
|
24
|
-
RuntimeHttpResponseBodyStream,
|
|
25
23
|
RuntimeKvEntry,
|
|
26
24
|
RuntimeKvListOptions,
|
|
27
25
|
RuntimeListenerConfig,
|
|
@@ -147,48 +145,23 @@ function toNapiApplication(application: RuntimeApplicationFetch) {
|
|
|
147
145
|
url: string;
|
|
148
146
|
headers: Record<string, string>;
|
|
149
147
|
body: Buffer;
|
|
150
|
-
cancelToken?: NativeCancellationToken;
|
|
151
|
-
responseBodyStream?: RuntimeHttpResponseBodyStream;
|
|
152
148
|
},
|
|
153
149
|
) => {
|
|
154
150
|
if (error) throw error;
|
|
155
151
|
if (!request) {
|
|
156
152
|
throw new Error("application fetch callback received no request");
|
|
157
153
|
}
|
|
158
|
-
const response = await application(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
cancelToken:
|
|
163
|
-
request.cancelToken as unknown as CancellationTokenHandle,
|
|
164
|
-
},
|
|
165
|
-
request.responseBodyStream
|
|
166
|
-
? fromNapiHttpResponseBodyStream(
|
|
167
|
-
request.responseBodyStream as unknown as NativeHttpResponseBodyStream,
|
|
168
|
-
)
|
|
169
|
-
: undefined,
|
|
170
|
-
);
|
|
154
|
+
const response = await application({
|
|
155
|
+
...request,
|
|
156
|
+
body: new Uint8Array(request.body),
|
|
157
|
+
});
|
|
171
158
|
return {
|
|
172
159
|
...response,
|
|
173
|
-
body:
|
|
174
|
-
response.body === undefined
|
|
175
|
-
? undefined
|
|
176
|
-
: toNapiBuffer(response.body),
|
|
160
|
+
body: toNapiBuffer(response.body),
|
|
177
161
|
};
|
|
178
162
|
};
|
|
179
163
|
}
|
|
180
164
|
|
|
181
|
-
function fromNapiHttpResponseBodyStream(
|
|
182
|
-
stream: NativeHttpResponseBodyStream,
|
|
183
|
-
): RuntimeHttpResponseBodyStream {
|
|
184
|
-
return {
|
|
185
|
-
cancelled: () => stream.cancelled(),
|
|
186
|
-
write: (chunk) => stream.write(Buffer.from(chunk)),
|
|
187
|
-
end: () => stream.end(),
|
|
188
|
-
error: (message) => stream.error(message),
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
|
|
192
165
|
function toNapiHttpRequest(
|
|
193
166
|
request?: RuntimeHttpRequest | undefined | null,
|
|
194
167
|
): Parameters<NativeActorContext["connectConn"]>[1] {
|