@rivetkit/engine-runner 2.0.27 → 2.0.29-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/src/stringify.ts CHANGED
@@ -40,8 +40,6 @@ export function stringifyToServerTunnelMessageKind(
40
40
  kind: protocol.ToServerTunnelMessageKind,
41
41
  ): string {
42
42
  switch (kind.tag) {
43
- case "DeprecatedTunnelAck":
44
- return "DeprecatedTunnelAck";
45
43
  case "ToServerResponseStart": {
46
44
  const { status, headers, body, stream } = kind.val;
47
45
  const bodyStr = body === null ? "null" : stringifyArrayBuffer(body);
@@ -82,8 +80,6 @@ export function stringifyToClientTunnelMessageKind(
82
80
  kind: protocol.ToClientTunnelMessageKind,
83
81
  ): string {
84
82
  switch (kind.tag) {
85
- case "DeprecatedTunnelAck":
86
- return "DeprecatedTunnelAck";
87
83
  case "ToClientRequestStart": {
88
84
  const { actorId, method, path, headers, body, stream } = kind.val;
89
85
  const bodyStr = body === null ? "null" : stringifyArrayBuffer(body);
@@ -119,7 +115,7 @@ export function stringifyToClientTunnelMessageKind(
119
115
  export function stringifyCommand(command: protocol.Command): string {
120
116
  switch (command.tag) {
121
117
  case "CommandStartActor": {
122
- const { actorId, generation, config, hibernatingRequests } =
118
+ const { config, hibernatingRequests } =
123
119
  command.val;
124
120
  const keyStr = config.key === null ? "null" : `"${config.key}"`;
125
121
  const inputStr =
@@ -130,11 +126,10 @@ export function stringifyCommand(command: protocol.Command): string {
130
126
  hibernatingRequests.length > 0
131
127
  ? `[${hibernatingRequests.map((hr) => `{gatewayId: ${idToStr(hr.gatewayId)}, requestId: ${idToStr(hr.requestId)}}`).join(", ")}]`
132
128
  : "[]";
133
- return `CommandStartActor{actorId: "${actorId}", generation: ${generation}, config: {name: "${config.name}", key: ${keyStr}, createTs: ${stringifyBigInt(config.createTs)}, input: ${inputStr}}, hibernatingRequests: ${hibernatingRequestsStr}}`;
129
+ return `CommandStartActor{config: {name: "${config.name}", key: ${keyStr}, createTs: ${stringifyBigInt(config.createTs)}, input: ${inputStr}}, hibernatingRequests: ${hibernatingRequestsStr}}`;
134
130
  }
135
131
  case "CommandStopActor": {
136
- const { actorId, generation } = command.val;
137
- return `CommandStopActor{actorId: "${actorId}", generation: ${generation}}`;
132
+ return `CommandStopActor`;
138
133
  }
139
134
  }
140
135
  }
@@ -146,7 +141,7 @@ export function stringifyCommand(command: protocol.Command): string {
146
141
  export function stringifyCommandWrapper(
147
142
  wrapper: protocol.CommandWrapper,
148
143
  ): string {
149
- return `CommandWrapper{index: ${stringifyBigInt(wrapper.index)}, inner: ${stringifyCommand(wrapper.inner)}}`;
144
+ return `CommandWrapper{actorId: "${wrapper.checkpoint.actorId}", generation: "${wrapper.checkpoint.generation}", index: ${stringifyBigInt(wrapper.checkpoint.index)}, inner: ${stringifyCommand(wrapper.inner)}}`;
150
145
  }
151
146
 
152
147
  /**
@@ -156,17 +151,17 @@ export function stringifyCommandWrapper(
156
151
  export function stringifyEvent(event: protocol.Event): string {
157
152
  switch (event.tag) {
158
153
  case "EventActorIntent": {
159
- const { actorId, generation, intent } = event.val;
154
+ const { intent } = event.val;
160
155
  const intentStr =
161
156
  intent.tag === "ActorIntentSleep"
162
157
  ? "Sleep"
163
158
  : intent.tag === "ActorIntentStop"
164
159
  ? "Stop"
165
160
  : "Unknown";
166
- return `EventActorIntent{actorId: "${actorId}", generation: ${generation}, intent: ${intentStr}}`;
161
+ return `EventActorIntent{intent: ${intentStr}}`;
167
162
  }
168
163
  case "EventActorStateUpdate": {
169
- const { actorId, generation, state } = event.val;
164
+ const { state } = event.val;
170
165
  let stateStr: string;
171
166
  if (state.tag === "ActorStateRunning") {
172
167
  stateStr = "Running";
@@ -177,13 +172,13 @@ export function stringifyEvent(event: protocol.Event): string {
177
172
  } else {
178
173
  stateStr = "Unknown";
179
174
  }
180
- return `EventActorStateUpdate{actorId: "${actorId}", generation: ${generation}, state: ${stateStr}}`;
175
+ return `EventActorStateUpdate{state: ${stateStr}}`;
181
176
  }
182
177
  case "EventActorSetAlarm": {
183
- const { actorId, generation, alarmTs } = event.val;
178
+ const { alarmTs } = event.val;
184
179
  const alarmTsStr =
185
180
  alarmTs === null ? "null" : stringifyBigInt(alarmTs);
186
- return `EventActorSetAlarm{actorId: "${actorId}", generation: ${generation}, alarmTs: ${alarmTsStr}}`;
181
+ return `EventActorSetAlarm{alarmTs: ${alarmTsStr}}`;
187
182
  }
188
183
  }
189
184
  }
@@ -193,7 +188,7 @@ export function stringifyEvent(event: protocol.Event): string {
193
188
  * Handles ArrayBuffers, BigInts, and Maps that can't be JSON.stringified
194
189
  */
195
190
  export function stringifyEventWrapper(wrapper: protocol.EventWrapper): string {
196
- return `EventWrapper{index: ${stringifyBigInt(wrapper.index)}, inner: ${stringifyEvent(wrapper.inner)}}`;
191
+ return `EventWrapper{actorId: ${wrapper.checkpoint.actorId}, generation: "${wrapper.checkpoint.generation}", index: ${stringifyBigInt(wrapper.checkpoint.index)}, inner: ${stringifyEvent(wrapper.inner)}}`;
197
192
  }
198
193
 
199
194
  /**
@@ -207,34 +202,33 @@ export function stringifyToServer(message: protocol.ToServer): string {
207
202
  name,
208
203
  version,
209
204
  totalSlots,
210
- lastCommandIdx,
211
205
  prepopulateActorNames,
212
206
  metadata,
213
207
  } = message.val;
214
- const lastCommandIdxStr =
215
- lastCommandIdx === null
216
- ? "null"
217
- : stringifyBigInt(lastCommandIdx);
218
208
  const prepopulateActorNamesStr =
219
209
  prepopulateActorNames === null
220
210
  ? "null"
221
211
  : `Map(${prepopulateActorNames.size})`;
222
212
  const metadataStr = metadata === null ? "null" : `"${metadata}"`;
223
- return `ToServerInit{name: "${name}", version: ${version}, totalSlots: ${totalSlots}, lastCommandIdx: ${lastCommandIdxStr}, prepopulateActorNames: ${prepopulateActorNamesStr}, metadata: ${metadataStr}}`;
213
+ return `ToServerInit{name: "${name}", version: ${version}, totalSlots: ${totalSlots}, prepopulateActorNames: ${prepopulateActorNamesStr}, metadata: ${metadataStr}}`;
224
214
  }
225
215
  case "ToServerEvents": {
226
216
  const events = message.val;
227
217
  return `ToServerEvents{count: ${events.length}, events: [${events.map((e) => stringifyEventWrapper(e)).join(", ")}]}`;
228
218
  }
229
219
  case "ToServerAckCommands": {
230
- const { lastCommandIdx } = message.val;
231
- return `ToServerAckCommands{lastCommandIdx: ${stringifyBigInt(lastCommandIdx)}}`;
220
+ const { lastCommandCheckpoints } = message.val;
221
+ const checkpointsStr =
222
+ lastCommandCheckpoints.length > 0
223
+ ? `[${lastCommandCheckpoints.map((cp) => `{actorId: "${cp.actorId}", index: ${stringifyBigInt(cp.index)}}`).join(", ")}]`
224
+ : "[]";
225
+ return `ToServerAckCommands{lastCommandCheckpoints: ${checkpointsStr}}`;
232
226
  }
233
227
  case "ToServerStopping":
234
228
  return "ToServerStopping";
235
- case "ToServerPing": {
229
+ case "ToServerPong": {
236
230
  const { ts } = message.val;
237
- return `ToServerPing{ts: ${stringifyBigInt(ts)}}`;
231
+ return `ToServerPong{ts: ${stringifyBigInt(ts)}}`;
238
232
  }
239
233
  case "ToServerKvRequest": {
240
234
  const { actorId, requestId, data } = message.val;
@@ -255,19 +249,24 @@ export function stringifyToServer(message: protocol.ToServer): string {
255
249
  export function stringifyToClient(message: protocol.ToClient): string {
256
250
  switch (message.tag) {
257
251
  case "ToClientInit": {
258
- const { runnerId, lastEventIdx, metadata } = message.val;
252
+ const { runnerId, metadata } = message.val;
259
253
  const metadataStr = `{runnerLostThreshold: ${stringifyBigInt(metadata.runnerLostThreshold)}}`;
260
- return `ToClientInit{runnerId: "${runnerId}", lastEventIdx: ${stringifyBigInt(lastEventIdx)}, metadata: ${metadataStr}}`;
254
+ return `ToClientInit{runnerId: "${runnerId}", metadata: ${metadataStr}}`;
261
255
  }
262
- case "ToClientClose":
263
- return "ToClientClose";
256
+ case "ToClientPing":
257
+ const { ts } = message.val;
258
+ return `ToClientPing{ts: ${stringifyBigInt(ts)}}`;
264
259
  case "ToClientCommands": {
265
260
  const commands = message.val;
266
261
  return `ToClientCommands{count: ${commands.length}, commands: [${commands.map((c) => stringifyCommandWrapper(c)).join(", ")}]}`;
267
262
  }
268
263
  case "ToClientAckEvents": {
269
- const { lastEventIdx } = message.val;
270
- return `ToClientAckEvents{lastEventIdx: ${stringifyBigInt(lastEventIdx)}}`;
264
+ const { lastEventCheckpoints } = message.val;
265
+ const checkpointsStr =
266
+ lastEventCheckpoints.length > 0
267
+ ? `[${lastEventCheckpoints.map((cp) => `{actorId: "${cp.actorId}", index: ${stringifyBigInt(cp.index)}}`).join(", ")}]`
268
+ : "[]";
269
+ return `ToClientAckEvents{lastEventCheckpoints: ${checkpointsStr}}`;
271
270
  }
272
271
  case "ToClientKvResponse": {
273
272
  const { requestId, data } = message.val;
package/src/tunnel.ts CHANGED
@@ -10,12 +10,12 @@ import {
10
10
  stringify as uuidstringify,
11
11
  v4 as uuidv4,
12
12
  } from "uuid";
13
- import type { Runner, RunnerActor } from "./mod";
13
+ import { RunnerShutdownError, type Runner, type RunnerActor } from "./mod";
14
14
  import {
15
15
  stringifyToClientTunnelMessageKind,
16
16
  stringifyToServerTunnelMessageKind,
17
17
  } from "./stringify";
18
- import { arraysEqual, idToStr, unreachable } from "./utils";
18
+ import { arraysEqual, idToStr, stringifyError, unreachable } from "./utils";
19
19
  import {
20
20
  HIBERNATABLE_SYMBOL,
21
21
  WebSocketTunnelAdapter,
@@ -41,12 +41,6 @@ export interface HibernatingWebSocketMetadata {
41
41
  headers: Record<string, string>;
42
42
  }
43
43
 
44
- class RunnerShutdownError extends Error {
45
- constructor() {
46
- super("Runner shut down");
47
- }
48
- }
49
-
50
44
  export class Tunnel {
51
45
  #runner: Runner;
52
46
 
@@ -226,7 +220,7 @@ export class Tunnel {
226
220
  this.log?.error({
227
221
  msg: "error creating websocket during restore",
228
222
  requestId: requestIdStr,
229
- err,
223
+ error: stringifyError(err),
230
224
  });
231
225
 
232
226
  // Close the WebSocket on error
@@ -291,7 +285,7 @@ export class Tunnel {
291
285
  this.log?.error({
292
286
  msg: "error creating stale websocket during restore",
293
287
  requestId: requestIdStr,
294
- err,
288
+ error: stringifyError(err),
295
289
  });
296
290
  });
297
291
 
@@ -671,9 +665,6 @@ export class Tunnel {
671
665
  message.messageKind.val,
672
666
  );
673
667
  break;
674
- case "DeprecatedTunnelAck":
675
- // Ignore deprecated tunnel ack messages
676
- break;
677
668
  default:
678
669
  unreachable(message.messageKind);
679
670
  }
package/src/utils.ts CHANGED
@@ -157,3 +157,19 @@ export function idToStr(id: ArrayBuffer): string {
157
157
  .map((byte) => byte.toString(16).padStart(2, "0"))
158
158
  .join("");
159
159
  }
160
+
161
+ export function stringifyError(error: unknown): string {
162
+ if (error instanceof Error) {
163
+ return `${error.name}: ${error.message}${error.stack ? `\n${error.stack}` : ""}`;
164
+ } else if (typeof error === "string") {
165
+ return error;
166
+ } else if (typeof error === "object" && error !== null) {
167
+ try {
168
+ return `${JSON.stringify(error)}`;
169
+ } catch {
170
+ return `[object ${error.constructor?.name || "Object"}]`;
171
+ }
172
+ } else {
173
+ return String(error);
174
+ }
175
+ }
@@ -1,22 +0,0 @@
1
-
2
- > @rivetkit/engine-runner@2.0.27 build /home/runner/work/rivet/rivet/engine/sdks/typescript/runner
3
- > tsup src/mod.ts
4
-
5
- CLI Building entry: src/mod.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Using tsup config: /home/runner/work/rivet/rivet/engine/sdks/typescript/runner/tsup.config.ts
9
- CLI Target: node16
10
- CLI Cleaning output folder
11
- CJS Build start
12
- ESM Build start
13
- DTS Build start
14
- ESM dist/mod.js 90.59 KB
15
- ESM dist/mod.js.map 179.70 KB
16
- ESM ⚡️ Build success in 444ms
17
- CJS dist/mod.cjs 91.64 KB
18
- CJS dist/mod.cjs.map 153.67 KB
19
- CJS ⚡️ Build success in 446ms
20
- DTS ⚡️ Build success in 1855ms
21
- DTS dist/mod.d.cts 14.48 KB
22
- DTS dist/mod.d.ts 14.48 KB
@@ -1,190 +0,0 @@
1
- // import { Bench } from "tinybench";
2
- // import { Runner } from "@/mod";
3
- // import type { ActorConfig } from "@/mod";
4
- // import {
5
- // createActor,
6
- // destroyActor,
7
- // setupBenchmarkRunner,
8
- // createPromiseResolver,
9
- // RIVET_ENDPOINT,
10
- // } from "./utils.js";
11
- // import { afterEach } from "node:test";
12
- //
13
- // async function runActorLifecycleBenchmark() {
14
- // // Shared state for benchmarks
15
- // let runner: Runner | null = null;
16
- // let namespaceName: string;
17
- // let runnerName: string;
18
- // let createdActors: string[] = [];
19
- // let wakeActorId: string | null = null;
20
- // let stopped: { promise: Promise<void>; resolve: () => void };
21
- // let started: { promise: Promise<void>; resolve: () => void };
22
- //
23
- // const bench = new Bench({
24
- // time: 1000,
25
- // iterations: 10,
26
- // warmupTime: 0,
27
- // warmupIterations: 0,
28
- // throws: true,
29
- // setup: async (task) => {
30
- // // Setup benchmark runner
31
- // console.log("Setting up benchmark runner...");
32
- // stopped = createPromiseResolver<void>();
33
- // started = createPromiseResolver<void>();
34
- //
35
- // const setup = await setupBenchmarkRunner(
36
- // "lifecycle",
37
- // 5054,
38
- // async (
39
- // _actorId: string,
40
- // _generation: number,
41
- // _config: ActorConfig,
42
- // ) => {
43
- // started.resolve();
44
- // },
45
- // async (_actorId: string, _generation: number) => {
46
- // stopped.resolve();
47
- // },
48
- // );
49
- // runner = setup.runner;
50
- // namespaceName = setup.namespaceName;
51
- // runnerName = setup.runnerName;
52
- //
53
- // console.log(
54
- // `Benchmark setup complete. Namespace: ${namespaceName}, Runner: ${runnerName}`,
55
- // );
56
- // },
57
- // teardown: async () => {
58
- // if (runner) {
59
- // await runner.shutdown(true);
60
- // }
61
- //
62
- // // Clean up created actors from creation benchmark
63
- // console.log(
64
- // `Cleaning up ${createdActors.length} actors in ${namespaceName}...`,
65
- // );
66
- // const cleanupActor = createdActors;
67
- // createdActors = [];
68
- // wakeActorId = null;
69
- // for (const actorId of cleanupActor) {
70
- // try {
71
- // await destroyActor(namespaceName, actorId);
72
- // } catch (err) {
73
- // console.warn(`Failed to clean up actor ${actorId}:`, err);
74
- // }
75
- // }
76
- //
77
- // console.log("Benchmark teardown complete!");
78
- // },
79
- // });
80
- //
81
- // bench.add("create actor", async () => {
82
- // const actorResponse = await createActor(
83
- // namespaceName,
84
- // runnerName,
85
- // false,
86
- // );
87
- // const actorId = actorResponse.actor.actor_id;
88
- // createdActors.push(actorId);
89
- //
90
- // // Ping the actor
91
- // const pingResponse = await fetch(`${RIVET_ENDPOINT}/ping`, {
92
- // method: "GET",
93
- // headers: {
94
- // "x-rivet-target": "actor",
95
- // "x-rivet-actor": actorId,
96
- // },
97
- // });
98
- // if (!pingResponse.ok) throw "Request failed";
99
- // });
100
- //
101
- // //bench.add(
102
- // // "wake actor from sleep",
103
- // // async () => {
104
- // // if (!wakeActorId) throw "No wake actor ID";
105
- // //
106
- // // // Ping the actor
107
- // // const pingResponse = await fetch(`${RIVET_ENDPOINT}/ping`, {
108
- // // method: "GET",
109
- // // headers: {
110
- // // "x-rivet-target": "actor",
111
- // // "x-rivet-actor": wakeActorId,
112
- // // },
113
- // // });
114
- // //
115
- // // if (!pingResponse.ok) {
116
- // // console.error(
117
- // // `Ping failed: ${pingResponse.status} ${pingResponse.statusText}`,
118
- // // );
119
- // // const errorText = await pingResponse.text();
120
- // // console.error(`Error response: ${errorText}`);
121
- // // throw `Request failed: ${pingResponse.status} ${pingResponse.statusText}`;
122
- // // }
123
- // // },
124
- // // {
125
- // // beforeEach: async () => {
126
- // // // Reset promise resolvers for this iteration
127
- // // started = createPromiseResolver<void>();
128
- // // stopped = createPromiseResolver<void>();
129
- // //
130
- // // // Create the actor that will be used for wake benchmarking
131
- // // console.log('Creating actor');
132
- // // const wakeActorResponse = await createActor(
133
- // // namespaceName,
134
- // // runnerName,
135
- // // false,
136
- // // "wake-bench-actor",
137
- // // );
138
- // // wakeActorId = wakeActorResponse.actor.actor_id;
139
- // // createdActors.push(wakeActorId!);
140
- // //
141
- // // // Wait for actor to start
142
- // // await started.promise;
143
- // //
144
- // // // Put actor to sleep initially
145
- // // runner!.sleepActor(wakeActorId!);
146
- // // await stopped.promise;
147
- // // },
148
- // // },
149
- // // // TODO(RVT-4979): Add back after sleep cycles fixed
150
- // // //{
151
- // // // beforeAll: async () => {
152
- // // // // Create the actor that will be used for wake benchmarking
153
- // // // console.log("Creating wake actor...");
154
- // // // const wakeActorResponse = await createActor(
155
- // // // namespaceName,
156
- // // // runnerName,
157
- // // // false,
158
- // // // "wake-bench-actor",
159
- // // // );
160
- // // // wakeActorId = wakeActorResponse.actor.actor_id;
161
- // // // createdActors.push(wakeActorId!);
162
- // // //
163
- // // // // Wait for actor to start
164
- // // // await started.promise;
165
- // // // },
166
- // // // beforeEach: async () => {
167
- // // // console.log("Putting actor to sleep...");
168
- // // //
169
- // // // // Put actor to sleep initially
170
- // // // stopped = createPromiseResolver<void>();
171
- // // // runner!.sleepActor(wakeActorId!);
172
- // // // await stopped.promise;
173
- // // // },
174
- // // //},
175
- // //);
176
- //
177
- // // Run the benchmark
178
- // console.log("Running benchmarks...");
179
- // await bench.run();
180
- //
181
- // // Display results
182
- // console.table(bench.table());
183
- //
184
- // console.log("Benchmark complete!");
185
- // }
186
- //
187
- // // Run the benchmark if this file is executed directly
188
- // if (import.meta.url === `file://${process.argv[1]}`) {
189
- // runActorLifecycleBenchmark();
190
- // }
package/benches/utils.ts DELETED
@@ -1,143 +0,0 @@
1
- // import { Runner } from "@/mod";
2
- // import type { RunnerConfig, ActorConfig } from "@/mod";
3
- //
4
- // export const RIVET_ENDPOINT =
5
- // process.env.RIVET_ENDPOINT ?? "http://localhost:6420";
6
- //
7
- // export async function createActor(
8
- // namespaceName: string,
9
- // runnerNameSelector: string,
10
- // durable: boolean,
11
- // actorName: string = "bench-actor",
12
- // ): Promise<any> {
13
- // const response = await fetch(
14
- // `${RIVET_ENDPOINT}/actors?namespace=${namespaceName}`,
15
- // {
16
- // method: "POST",
17
- // headers: {
18
- // "Content-Type": "application/json",
19
- // },
20
- // body: JSON.stringify({
21
- // name: actorName,
22
- // input: btoa("bench-input"),
23
- // runner_name_selector: runnerNameSelector,
24
- // durable,
25
- // }),
26
- // },
27
- // );
28
- //
29
- // if (!response.ok) {
30
- // throw new Error(
31
- // `Failed to create actor: ${response.status} ${response.statusText}\n${await response.text()}`,
32
- // );
33
- // }
34
- //
35
- // return response.json();
36
- // }
37
- //
38
- // export async function destroyActor(
39
- // namespaceName: string,
40
- // actorId: string,
41
- // ): Promise<void> {
42
- // const response = await fetch(
43
- // `${RIVET_ENDPOINT}/actors/${actorId}?namespace=${namespaceName}`,
44
- // {
45
- // method: "DELETE",
46
- // },
47
- // );
48
- //
49
- // if (!response.ok) {
50
- // throw new Error(
51
- // `Failed to delete actor: ${response.status} ${response.statusText}\n${await response.text()}`,
52
- // );
53
- // }
54
- // }
55
- //
56
- // export async function createNamespace(
57
- // name: string,
58
- // displayName: string,
59
- // ): Promise<any> {
60
- // const response = await fetch(`${RIVET_ENDPOINT}/namespaces`, {
61
- // method: "POST",
62
- // headers: {
63
- // "Content-Type": "application/json",
64
- // },
65
- // body: JSON.stringify({
66
- // name,
67
- // display_name: displayName,
68
- // }),
69
- // });
70
- //
71
- // if (!response.ok) {
72
- // console.warn(
73
- // `Failed to create namespace: ${response.status} ${response.statusText}\n${await response.text()}`,
74
- // );
75
- // }
76
- // }
77
- //
78
- // export interface BenchmarkRunnerSetup {
79
- // runner: Runner;
80
- // namespaceName: string;
81
- // runnerName: string;
82
- // }
83
- //
84
- // export async function setupBenchmarkRunner(
85
- // namespaceSuffix: string,
86
- // port: number,
87
- // onActorStart?: (
88
- // actorId: string,
89
- // generation: number,
90
- // config: ActorConfig,
91
- // ) => Promise<void>,
92
- // onActorStop?: (actorId: string, generation: number) => Promise<void>,
93
- // ): Promise<BenchmarkRunnerSetup> {
94
- // const namespaceName = `bench-${crypto.randomUUID().slice(0, 8)}`;
95
- // const runnerName = `bench-runner`;
96
- //
97
- // let runnerStartedResolver: () => void;
98
- // const runnerStarted = new Promise<void>((resolve) => {
99
- // runnerStartedResolver = resolve;
100
- // });
101
- //
102
- // const config: RunnerConfig = {
103
- // version: 1,
104
- // endpoint: RIVET_ENDPOINT,
105
- // namespace: namespaceName,
106
- // addresses: { main: { host: "127.0.0.1", port } },
107
- // totalSlots: 100,
108
- // prepopulateActorNames: [],
109
- // runnerName: runnerName,
110
- // runnerKey: "default",
111
- // onConnected: () => {
112
- // runnerStartedResolver();
113
- // },
114
- // onDisconnected: () => {},
115
- // fetch: async (_actorId: string, request: Request) => {
116
- // return new Response("ok", { status: 200 });
117
- // },
118
- // onActorStart: onActorStart || (async () => {}),
119
- // onActorStop: onActorStop || (async () => {}),
120
- // };
121
- //
122
- // await createNamespace(namespaceName, `Bench ${namespaceSuffix} Namespace`);
123
- // const runner = new Runner(config);
124
- // runner.start();
125
- // await runnerStarted;
126
- //
127
- // return { runner, namespaceName, runnerName };
128
- // }
129
- //
130
- // export function createPromiseResolver<T = void>(): {
131
- // promise: Promise<T>;
132
- // resolve: (value: T) => void;
133
- // reject: (error: any) => void;
134
- // } {
135
- // let resolve: (value: T) => void;
136
- // let reject: (error: any) => void;
137
- // const promise = new Promise<T>((res, rej) => {
138
- // resolve = res;
139
- // reject = rej;
140
- // });
141
- // return { promise, resolve: resolve!, reject: reject! };
142
- // }
143
- //