rivetkit 2.3.8 → 2.3.10
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 +6 -34
- package/dist/browser/client.js +14 -33
- 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 +6 -34
- package/dist/tsup/agent-os/index.d.ts +6 -34
- package/dist/tsup/agent-os/index.js +1 -1
- package/dist/tsup/agent-os/index.js.map +1 -1
- package/dist/tsup/{chunk-YFXQ7DBH.js → chunk-6UHZLL6S.js} +3 -3
- package/dist/tsup/{chunk-BL6ERZQO.js → chunk-DPM73GAL.js} +18 -39
- package/dist/tsup/chunk-DPM73GAL.js.map +1 -0
- package/dist/tsup/{chunk-MY6BRV3S.js → chunk-E6IEX6AP.js} +3 -3
- package/dist/tsup/{chunk-IJMVVULS.cjs → chunk-G6XA2OSW.cjs} +4 -4
- package/dist/tsup/{chunk-IJMVVULS.cjs.map → chunk-G6XA2OSW.cjs.map} +1 -1
- package/dist/tsup/{chunk-F6GCLL5Z.cjs → chunk-INXPYXN6.cjs} +7 -7
- package/dist/tsup/{chunk-F6GCLL5Z.cjs.map → chunk-INXPYXN6.cjs.map} +1 -1
- package/dist/tsup/{chunk-5MJPN3QU.cjs → chunk-LCWHS6K7.cjs} +152 -173
- package/dist/tsup/chunk-LCWHS6K7.cjs.map +1 -0
- package/dist/tsup/{chunk-7TNEDX3Y.cjs → chunk-PCJSDS7N.cjs} +3 -3
- package/dist/tsup/{chunk-7TNEDX3Y.cjs.map → chunk-PCJSDS7N.cjs.map} +1 -1
- package/dist/tsup/{chunk-V7PJYBA5.js → chunk-Q5H37KNQ.js} +2 -2
- package/dist/tsup/{chunk-TMTJPSHQ.cjs → chunk-U2A3Y7OK.cjs} +9 -9
- package/dist/tsup/{chunk-TMTJPSHQ.cjs.map → chunk-U2A3Y7OK.cjs.map} +1 -1
- package/dist/tsup/{chunk-ZKDZW5DQ.js → chunk-X7XY6NCU.js} +3 -6
- package/dist/tsup/chunk-X7XY6NCU.js.map +1 -0
- package/dist/tsup/{chunk-HWBISPRP.js → chunk-XSPAARQ5.js} +2 -2
- package/dist/tsup/{chunk-NUMGL52R.cjs → chunk-Z2ESFE5Z.cjs} +3 -6
- package/dist/tsup/chunk-Z2ESFE5Z.cjs.map +1 -0
- 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-BRpVbJCD.d.ts} +7 -35
- package/dist/tsup/{config-CpB-e4I9.d.cts → config-BobvQpex.d.cts} +7 -35
- package/dist/tsup/{context-YBUBTwTS.d.ts → context-Cj-DFyiy.d.ts} +1 -1
- package/dist/tsup/{context-c-6G4mjk.d.cts → context-YEBNJrws.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 +124 -449
- 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 +63 -388
- 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 +2 -11
- package/src/common/actor-router-consts.ts +0 -1
- package/src/common/encoding.ts +1 -4
- package/src/engine-client/actor-http-client.ts +22 -6
- package/src/registry/index.ts +14 -159
- package/src/registry/napi-runtime.ts +0 -74
- package/src/registry/native.ts +63 -111
- package/src/registry/runtime.ts +0 -35
- package/src/registry/wasm-runtime.ts +0 -11
- package/dist/tsup/chunk-5MJPN3QU.cjs.map +0 -1
- package/dist/tsup/chunk-BL6ERZQO.js.map +0 -1
- package/dist/tsup/chunk-NUMGL52R.cjs.map +0 -1
- package/dist/tsup/chunk-ZKDZW5DQ.js.map +0 -1
- package/src/common/fetch-like.ts +0 -49
- package/src/registry/native-http.ts +0 -208
- /package/dist/tsup/{chunk-YFXQ7DBH.js.map → chunk-6UHZLL6S.js.map} +0 -0
- /package/dist/tsup/{chunk-MY6BRV3S.js.map → chunk-E6IEX6AP.js.map} +0 -0
- /package/dist/tsup/{chunk-V7PJYBA5.js.map → chunk-Q5H37KNQ.js.map} +0 -0
- /package/dist/tsup/{chunk-HWBISPRP.js.map → chunk-XSPAARQ5.js.map} +0 -0
|
@@ -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 {
|
|
@@ -15,13 +14,10 @@ import type {
|
|
|
15
14
|
CoreRuntime,
|
|
16
15
|
RegistryHandle,
|
|
17
16
|
RuntimeActorConfig,
|
|
18
|
-
RuntimeApplicationFetch,
|
|
19
|
-
RuntimeApplicationListenerConfig,
|
|
20
17
|
RuntimeBytes,
|
|
21
18
|
RuntimeCronFire,
|
|
22
19
|
RuntimeCronJobInfo,
|
|
23
20
|
RuntimeHttpRequest,
|
|
24
|
-
RuntimeHttpResponseBodyStream,
|
|
25
21
|
RuntimeKvEntry,
|
|
26
22
|
RuntimeKvListOptions,
|
|
27
23
|
RuntimeListenerConfig,
|
|
@@ -139,56 +135,6 @@ function toNapiBuffer(value: RuntimeBytes): Buffer {
|
|
|
139
135
|
return Buffer.from(value);
|
|
140
136
|
}
|
|
141
137
|
|
|
142
|
-
function toNapiApplication(application: RuntimeApplicationFetch) {
|
|
143
|
-
return async (
|
|
144
|
-
error: unknown,
|
|
145
|
-
request?: {
|
|
146
|
-
method: string;
|
|
147
|
-
url: string;
|
|
148
|
-
headers: Record<string, string>;
|
|
149
|
-
body: Buffer;
|
|
150
|
-
cancelToken?: NativeCancellationToken;
|
|
151
|
-
responseBodyStream?: RuntimeHttpResponseBodyStream;
|
|
152
|
-
},
|
|
153
|
-
) => {
|
|
154
|
-
if (error) throw error;
|
|
155
|
-
if (!request) {
|
|
156
|
-
throw new Error("application fetch callback received no request");
|
|
157
|
-
}
|
|
158
|
-
const response = await application(
|
|
159
|
-
{
|
|
160
|
-
...request,
|
|
161
|
-
body: new Uint8Array(request.body),
|
|
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
|
-
);
|
|
171
|
-
return {
|
|
172
|
-
...response,
|
|
173
|
-
body:
|
|
174
|
-
response.body === undefined
|
|
175
|
-
? undefined
|
|
176
|
-
: toNapiBuffer(response.body),
|
|
177
|
-
};
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
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
138
|
function toNapiHttpRequest(
|
|
193
139
|
request?: RuntimeHttpRequest | undefined | null,
|
|
194
140
|
): Parameters<NativeActorContext["connectConn"]>[1] {
|
|
@@ -350,9 +296,6 @@ export class NapiCoreRuntime implements CoreRuntime {
|
|
|
350
296
|
listener: RuntimeListenerConfig,
|
|
351
297
|
config: RuntimeServeConfig,
|
|
352
298
|
): Promise<void> {
|
|
353
|
-
const application = listener.application
|
|
354
|
-
? toNapiApplication(listener.application)
|
|
355
|
-
: undefined;
|
|
356
299
|
await asNativeRegistry(registry).serveListener(
|
|
357
300
|
{
|
|
358
301
|
port: listener.port,
|
|
@@ -360,23 +303,6 @@ export class NapiCoreRuntime implements CoreRuntime {
|
|
|
360
303
|
publicDir: listener.publicDir,
|
|
361
304
|
},
|
|
362
305
|
config,
|
|
363
|
-
application,
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
async serveApplicationListener(
|
|
368
|
-
registry: RegistryHandle,
|
|
369
|
-
listener: RuntimeApplicationListenerConfig,
|
|
370
|
-
config: RuntimeServeConfig,
|
|
371
|
-
): Promise<void> {
|
|
372
|
-
await asNativeRegistry(registry).serveApplicationListener(
|
|
373
|
-
{
|
|
374
|
-
port: listener.port,
|
|
375
|
-
host: listener.host,
|
|
376
|
-
publicDir: listener.publicDir,
|
|
377
|
-
},
|
|
378
|
-
toNapiApplication(listener.application),
|
|
379
|
-
config,
|
|
380
306
|
);
|
|
381
307
|
}
|
|
382
308
|
|
package/src/registry/native.ts
CHANGED
|
@@ -47,7 +47,6 @@ import { HEADER_CONN_PARAMS } from "@/common/actor-router-consts";
|
|
|
47
47
|
import type { AnyDatabaseProvider } from "@/common/database/config";
|
|
48
48
|
import { wrapJsNativeDatabase } from "@/common/database/native-database";
|
|
49
49
|
import { assertJsonCompatValue, type JsonCompatValue } from "@/common/encoding";
|
|
50
|
-
import { isResponseLike } from "@/common/fetch-like";
|
|
51
50
|
import { decodeWorkflowHistoryTransport } from "@/common/inspector-transport";
|
|
52
51
|
import { deconstructError, stringifyError } from "@/common/utils";
|
|
53
52
|
import type {
|
|
@@ -72,13 +71,6 @@ import {
|
|
|
72
71
|
} from "@/utils/node";
|
|
73
72
|
import { logger } from "./log";
|
|
74
73
|
import { loadNapiRuntime } from "./napi-runtime";
|
|
75
|
-
import {
|
|
76
|
-
buildNativeHttpRequest,
|
|
77
|
-
cancelNativeHttpRequestBody,
|
|
78
|
-
convertNativeHttpResponse,
|
|
79
|
-
type NativeHttpRequestBodyStream,
|
|
80
|
-
type NativeHttpResponseBodyStream,
|
|
81
|
-
} from "./native-http";
|
|
82
74
|
import {
|
|
83
75
|
type NativeValidationConfig,
|
|
84
76
|
validateActionArgs,
|
|
@@ -98,6 +90,7 @@ import type {
|
|
|
98
90
|
RuntimeBytes,
|
|
99
91
|
RuntimeCronFire,
|
|
100
92
|
RuntimeCronJobInfo,
|
|
93
|
+
RuntimeHttpResponse,
|
|
101
94
|
RuntimeInspectorTabEntry,
|
|
102
95
|
RuntimeQueueMessage,
|
|
103
96
|
RuntimeScheduledEventInfo,
|
|
@@ -1169,6 +1162,38 @@ function decodeArgs(value?: RuntimeBytes | null): unknown[] {
|
|
|
1169
1162
|
return normalizeArgs(decoded);
|
|
1170
1163
|
}
|
|
1171
1164
|
|
|
1165
|
+
function buildRequest(init: {
|
|
1166
|
+
method: string;
|
|
1167
|
+
uri: string;
|
|
1168
|
+
headers?: Record<string, string>;
|
|
1169
|
+
body?: RuntimeBytes;
|
|
1170
|
+
}): Request {
|
|
1171
|
+
const url = init.uri.startsWith("http")
|
|
1172
|
+
? init.uri
|
|
1173
|
+
: new URL(init.uri, "http://127.0.0.1").toString();
|
|
1174
|
+
const body =
|
|
1175
|
+
init.body && init.body.length > 0
|
|
1176
|
+
? runtimeBytesToArrayBuffer(init.body)
|
|
1177
|
+
: undefined;
|
|
1178
|
+
return new Request(url, {
|
|
1179
|
+
method: init.method,
|
|
1180
|
+
headers: init.headers,
|
|
1181
|
+
body,
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
async function toRuntimeHttpResponse(
|
|
1186
|
+
response: Response,
|
|
1187
|
+
): Promise<RuntimeHttpResponse> {
|
|
1188
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
1189
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
1190
|
+
return {
|
|
1191
|
+
status: response.status,
|
|
1192
|
+
headers,
|
|
1193
|
+
body,
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1172
1197
|
function toActorKey(
|
|
1173
1198
|
segments: Array<{
|
|
1174
1199
|
kind: string;
|
|
@@ -3690,22 +3715,19 @@ export function buildNativeFactory(
|
|
|
3690
3715
|
);
|
|
3691
3716
|
const maybeHandleNativeInspectorRequest = async (
|
|
3692
3717
|
ctx: ActorContextHandle,
|
|
3693
|
-
|
|
3718
|
+
_rawRequest: {
|
|
3694
3719
|
method: string;
|
|
3695
3720
|
uri: string;
|
|
3696
3721
|
headers?: Record<string, string>;
|
|
3697
3722
|
body?: RuntimeBytes;
|
|
3698
3723
|
},
|
|
3724
|
+
jsRequest: Request,
|
|
3699
3725
|
): Promise<Response | undefined> => {
|
|
3700
|
-
const
|
|
3701
|
-
? rawRequest.uri
|
|
3702
|
-
: new URL(rawRequest.uri, "http://127.0.0.1").toString();
|
|
3703
|
-
const url = new URL(rawUrl);
|
|
3726
|
+
const url = new URL(jsRequest.url);
|
|
3704
3727
|
if (!url.pathname.startsWith("/inspector/")) {
|
|
3705
3728
|
return undefined;
|
|
3706
3729
|
}
|
|
3707
3730
|
|
|
3708
|
-
const jsRequest = buildNativeHttpRequest(rawRequest);
|
|
3709
3731
|
const jsonResponse = (body: unknown, init?: ResponseInit) =>
|
|
3710
3732
|
new Response(JSON.stringify(body), {
|
|
3711
3733
|
status: init?.status ?? 200,
|
|
@@ -4397,9 +4419,7 @@ export function buildNativeFactory(
|
|
|
4397
4419
|
);
|
|
4398
4420
|
const actorCtx = makeActorCtx(
|
|
4399
4421
|
ctx,
|
|
4400
|
-
request
|
|
4401
|
-
? buildNativeHttpRequest(request)
|
|
4402
|
-
: undefined,
|
|
4422
|
+
request ? buildRequest(request) : undefined,
|
|
4403
4423
|
);
|
|
4404
4424
|
try {
|
|
4405
4425
|
await config.onBeforeConnect(
|
|
@@ -4436,9 +4456,7 @@ export function buildNativeFactory(
|
|
|
4436
4456
|
unwrapTsfnPayload(error, payload);
|
|
4437
4457
|
const actorCtx = makeActorCtx(
|
|
4438
4458
|
ctx,
|
|
4439
|
-
request
|
|
4440
|
-
? buildNativeHttpRequest(request)
|
|
4441
|
-
: undefined,
|
|
4459
|
+
request ? buildRequest(request) : undefined,
|
|
4442
4460
|
);
|
|
4443
4461
|
const connAdapter = new NativeConnAdapter(
|
|
4444
4462
|
runtime,
|
|
@@ -4493,9 +4511,7 @@ export function buildNativeFactory(
|
|
|
4493
4511
|
);
|
|
4494
4512
|
const actorCtx = makeActorCtx(
|
|
4495
4513
|
ctx,
|
|
4496
|
-
request
|
|
4497
|
-
? buildNativeHttpRequest(request)
|
|
4498
|
-
: undefined,
|
|
4514
|
+
request ? buildRequest(request) : undefined,
|
|
4499
4515
|
);
|
|
4500
4516
|
const connAdapter = new NativeConnAdapter(
|
|
4501
4517
|
runtime,
|
|
@@ -4645,63 +4661,38 @@ export function buildNativeFactory(
|
|
|
4645
4661
|
uri: string;
|
|
4646
4662
|
headers?: Record<string, string>;
|
|
4647
4663
|
body?: RuntimeBytes;
|
|
4648
|
-
bodyStream?: NativeHttpRequestBodyStream;
|
|
4649
4664
|
};
|
|
4650
4665
|
cancelToken?: CancellationTokenHandle;
|
|
4651
|
-
responseBodyStream?: NativeHttpResponseBodyStream;
|
|
4652
4666
|
},
|
|
4653
4667
|
) => {
|
|
4654
4668
|
try {
|
|
4655
|
-
const { ctx, request, cancelToken
|
|
4656
|
-
|
|
4669
|
+
const { ctx, request, cancelToken } = unwrapTsfnPayload(
|
|
4670
|
+
error,
|
|
4671
|
+
payload,
|
|
4672
|
+
);
|
|
4673
|
+
const jsRequest = buildRequest(request);
|
|
4657
4674
|
const inspectorResponse =
|
|
4658
|
-
await maybeHandleNativeInspectorRequest(
|
|
4675
|
+
await maybeHandleNativeInspectorRequest(
|
|
4676
|
+
ctx,
|
|
4677
|
+
request,
|
|
4678
|
+
jsRequest,
|
|
4679
|
+
);
|
|
4659
4680
|
if (inspectorResponse) {
|
|
4660
|
-
await
|
|
4661
|
-
return (
|
|
4662
|
-
await convertNativeHttpResponse(
|
|
4663
|
-
inspectorResponse,
|
|
4664
|
-
responseBodyStream,
|
|
4665
|
-
)
|
|
4666
|
-
).response;
|
|
4681
|
+
return await toRuntimeHttpResponse(inspectorResponse);
|
|
4667
4682
|
}
|
|
4668
4683
|
|
|
4669
4684
|
if (typeof config.onRequest !== "function") {
|
|
4670
|
-
await
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
new Response(null, { status: 404 }),
|
|
4674
|
-
responseBodyStream,
|
|
4675
|
-
)
|
|
4676
|
-
).response;
|
|
4685
|
+
return await toRuntimeHttpResponse(
|
|
4686
|
+
new Response(null, { status: 404 }),
|
|
4687
|
+
);
|
|
4677
4688
|
}
|
|
4678
4689
|
|
|
4679
|
-
const requestAbortController = new AbortController();
|
|
4680
|
-
const handlerRequest = buildNativeHttpRequest({
|
|
4681
|
-
...request,
|
|
4682
|
-
abortController: requestAbortController,
|
|
4683
|
-
});
|
|
4684
4690
|
const rawConnParams =
|
|
4685
|
-
|
|
4691
|
+
jsRequest.headers.get(HEADER_CONN_PARAMS);
|
|
4686
4692
|
let requestCtx:
|
|
4687
4693
|
| ReturnType<typeof withConnContext>
|
|
4688
4694
|
| undefined;
|
|
4689
4695
|
let conn: ConnHandle | undefined;
|
|
4690
|
-
let removeRequestAbortListener: (() => void) | undefined;
|
|
4691
|
-
let cleanupDeferredToBody = false;
|
|
4692
|
-
let cleanedUp = false;
|
|
4693
|
-
const cleanupRequest = async () => {
|
|
4694
|
-
if (cleanedUp) return;
|
|
4695
|
-
cleanedUp = true;
|
|
4696
|
-
removeRequestAbortListener?.();
|
|
4697
|
-
try {
|
|
4698
|
-
await requestCtx?.dispose();
|
|
4699
|
-
} finally {
|
|
4700
|
-
if (conn) {
|
|
4701
|
-
await runtime.connDisconnect(conn);
|
|
4702
|
-
}
|
|
4703
|
-
}
|
|
4704
|
-
};
|
|
4705
4696
|
try {
|
|
4706
4697
|
const connParams = validateConnParams(
|
|
4707
4698
|
schemaConfig.connParamsSchema,
|
|
@@ -4719,62 +4710,23 @@ export function buildNativeFactory(
|
|
|
4719
4710
|
requestCtx = makeConnCtx(
|
|
4720
4711
|
ctx,
|
|
4721
4712
|
conn,
|
|
4722
|
-
|
|
4713
|
+
jsRequest,
|
|
4723
4714
|
cancelToken,
|
|
4724
4715
|
);
|
|
4725
|
-
const ctxAbortSignal = requestCtx.abortSignal;
|
|
4726
|
-
const abortRequest = () =>
|
|
4727
|
-
requestAbortController.abort(ctxAbortSignal.reason);
|
|
4728
|
-
if (ctxAbortSignal.aborted) {
|
|
4729
|
-
abortRequest();
|
|
4730
|
-
} else {
|
|
4731
|
-
ctxAbortSignal.addEventListener(
|
|
4732
|
-
"abort",
|
|
4733
|
-
abortRequest,
|
|
4734
|
-
{ once: true },
|
|
4735
|
-
);
|
|
4736
|
-
removeRequestAbortListener = () =>
|
|
4737
|
-
ctxAbortSignal.removeEventListener(
|
|
4738
|
-
"abort",
|
|
4739
|
-
abortRequest,
|
|
4740
|
-
);
|
|
4741
|
-
}
|
|
4742
4716
|
const response = await config.onRequest(
|
|
4743
4717
|
requestCtx,
|
|
4744
|
-
|
|
4718
|
+
jsRequest,
|
|
4745
4719
|
);
|
|
4746
|
-
if (!
|
|
4720
|
+
if (!(response instanceof Response)) {
|
|
4747
4721
|
throw new Error(
|
|
4748
4722
|
"onRequest handler must return a Response",
|
|
4749
4723
|
);
|
|
4750
4724
|
}
|
|
4751
|
-
|
|
4752
|
-
response,
|
|
4753
|
-
responseBodyStream,
|
|
4754
|
-
);
|
|
4755
|
-
if (conversion.bodyCompletion) {
|
|
4756
|
-
cleanupDeferredToBody = true;
|
|
4757
|
-
void conversion.bodyCompletion
|
|
4758
|
-
.then(cleanupRequest)
|
|
4759
|
-
.catch((cleanupError) => {
|
|
4760
|
-
logger().error({
|
|
4761
|
-
msg: "failed to clean up native streaming http request",
|
|
4762
|
-
error: cleanupError,
|
|
4763
|
-
});
|
|
4764
|
-
});
|
|
4765
|
-
}
|
|
4766
|
-
return conversion.response;
|
|
4725
|
+
return await toRuntimeHttpResponse(response);
|
|
4767
4726
|
} finally {
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
await cancelNativeHttpRequestBody(
|
|
4772
|
-
request.bodyStream,
|
|
4773
|
-
);
|
|
4774
|
-
} finally {
|
|
4775
|
-
if (!cleanupDeferredToBody) {
|
|
4776
|
-
await cleanupRequest();
|
|
4777
|
-
}
|
|
4727
|
+
await requestCtx?.dispose();
|
|
4728
|
+
if (conn) {
|
|
4729
|
+
await runtime.connDisconnect(conn);
|
|
4778
4730
|
}
|
|
4779
4731
|
}
|
|
4780
4732
|
} catch (error) {
|
|
@@ -4806,7 +4758,7 @@ export function buildNativeFactory(
|
|
|
4806
4758
|
const { ctx, conn, ws, request } =
|
|
4807
4759
|
unwrapTsfnPayload(error, payload);
|
|
4808
4760
|
const jsRequest = request
|
|
4809
|
-
?
|
|
4761
|
+
? buildRequest(request)
|
|
4810
4762
|
: undefined;
|
|
4811
4763
|
const actorCtx = makeConnCtx(ctx, conn, jsRequest);
|
|
4812
4764
|
try {
|
|
@@ -4966,7 +4918,7 @@ export function buildNativeFactory(
|
|
|
4966
4918
|
timeoutMs,
|
|
4967
4919
|
cancelToken,
|
|
4968
4920
|
} = unwrapTsfnPayload(error, payload);
|
|
4969
|
-
const jsRequest =
|
|
4921
|
+
const jsRequest = buildRequest(request);
|
|
4970
4922
|
const actorCtx = withConnContext(
|
|
4971
4923
|
runtime,
|
|
4972
4924
|
ctx,
|
package/src/registry/runtime.ts
CHANGED
|
@@ -36,14 +36,6 @@ export interface RuntimeHttpResponse {
|
|
|
36
36
|
status?: number;
|
|
37
37
|
headers?: Record<string, string>;
|
|
38
38
|
body?: RuntimeBytes;
|
|
39
|
-
stream?: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface RuntimeHttpResponseBodyStream {
|
|
43
|
-
cancelled(): Promise<void>;
|
|
44
|
-
write(chunk: Uint8Array): Promise<void>;
|
|
45
|
-
end(): Promise<void>;
|
|
46
|
-
error(message: string): Promise<void>;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
export interface RuntimeStateDeltaPayload {
|
|
@@ -354,7 +346,6 @@ export interface RuntimeListenerConfig {
|
|
|
354
346
|
port: number;
|
|
355
347
|
host?: string;
|
|
356
348
|
publicDir?: string;
|
|
357
|
-
application?: RuntimeApplicationFetch;
|
|
358
349
|
}
|
|
359
350
|
|
|
360
351
|
export interface RuntimeServerlessRequest {
|
|
@@ -364,27 +355,6 @@ export interface RuntimeServerlessRequest {
|
|
|
364
355
|
body: RuntimeBytes;
|
|
365
356
|
}
|
|
366
357
|
|
|
367
|
-
export interface RuntimeApplicationRequest extends RuntimeServerlessRequest {
|
|
368
|
-
cancelToken?: CancellationTokenHandle;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export interface RuntimeApplicationResponse {
|
|
372
|
-
status: number;
|
|
373
|
-
headers: Record<string, string>;
|
|
374
|
-
body?: RuntimeBytes;
|
|
375
|
-
stream?: boolean;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
export type RuntimeApplicationFetch = (
|
|
379
|
-
request: RuntimeApplicationRequest,
|
|
380
|
-
responseBodyStream?: RuntimeHttpResponseBodyStream,
|
|
381
|
-
) => Promise<RuntimeApplicationResponse>;
|
|
382
|
-
|
|
383
|
-
export interface RuntimeApplicationListenerConfig
|
|
384
|
-
extends RuntimeListenerConfig {
|
|
385
|
-
application: RuntimeApplicationFetch;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
358
|
export interface RuntimeServerlessResponseHead {
|
|
389
359
|
status: number;
|
|
390
360
|
headers: Record<string, string>;
|
|
@@ -459,11 +429,6 @@ export interface CoreRuntime {
|
|
|
459
429
|
listener: RuntimeListenerConfig,
|
|
460
430
|
config: RuntimeServeConfig,
|
|
461
431
|
): Promise<void>;
|
|
462
|
-
serveApplicationListener(
|
|
463
|
-
registry: RegistryHandle,
|
|
464
|
-
listener: RuntimeApplicationListenerConfig,
|
|
465
|
-
config: RuntimeServeConfig,
|
|
466
|
-
): Promise<void>;
|
|
467
432
|
registryHealth?(
|
|
468
433
|
registry: RegistryHandle,
|
|
469
434
|
): Promise<RuntimeRegistryRouteResponse>;
|
|
@@ -21,7 +21,6 @@ import type {
|
|
|
21
21
|
RegistryHandle,
|
|
22
22
|
RuntimeActorConfig,
|
|
23
23
|
RuntimeActorKeySegment,
|
|
24
|
-
RuntimeApplicationListenerConfig,
|
|
25
24
|
RuntimeBytes,
|
|
26
25
|
RuntimeHttpRequest,
|
|
27
26
|
RuntimeInspectorSnapshot,
|
|
@@ -326,16 +325,6 @@ export class WasmCoreRuntime implements CoreRuntime {
|
|
|
326
325
|
);
|
|
327
326
|
}
|
|
328
327
|
|
|
329
|
-
async serveApplicationListener(
|
|
330
|
-
_registry: RegistryHandle,
|
|
331
|
-
_listener: RuntimeApplicationListenerConfig,
|
|
332
|
-
_config: RuntimeServeConfig,
|
|
333
|
-
): Promise<void> {
|
|
334
|
-
throw new Error(
|
|
335
|
-
"registry.listen() is not supported on the wasm runtime; use an application-owned HTTP server instead",
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
328
|
createActorFactory(
|
|
340
329
|
callbacks: object,
|
|
341
330
|
config?: RuntimeActorConfig | undefined | null,
|