Skip to content

Commit 3763786

Browse files
committed
fix(rivetkit): fix duplicate runner key in serverless
1 parent 422a612 commit 3763786

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

rivetkit-typescript/packages/rivetkit/src/drivers/engine/actor-driver.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class EngineActorDriver implements ActorDriver {
9999

100100
// HACK: Override inspector token (which are likely to be
101101
// removed later on) with token from x-rivet-token header
102-
const token = runConfig.token ?? runConfig.token;
102+
const token = runConfig.token;
103103
if (token && runConfig.inspector && runConfig.inspector.enabled) {
104104
runConfig.inspector.token = () => token;
105105
}
@@ -116,10 +116,10 @@ export class EngineActorDriver implements ActorDriver {
116116
version: this.#version,
117117
endpoint: getEndpoint(runConfig),
118118
token,
119-
namespace: runConfig.namespace ?? runConfig.namespace,
120-
totalSlots: runConfig.totalSlots ?? runConfig.totalSlots,
121-
runnerName: runConfig.runnerName ?? runConfig.runnerName,
122-
runnerKey: runConfig.runnerKey,
119+
namespace: runConfig.namespace,
120+
totalSlots: runConfig.totalSlots,
121+
runnerName: runConfig.runnerName,
122+
runnerKey: runConfig.runnerKey ?? crypto.randomUUID(),
123123
metadata: {
124124
inspectorToken: this.#runConfig.inspector.token(),
125125
},

rivetkit-typescript/packages/rivetkit/src/drivers/engine/config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ export const EngingConfigSchema = z
77
/** Unique key for this runner. Runners connecting a given key will replace any other runner connected with the same key. */
88
runnerKey: z
99
.string()
10-
.default(
11-
() =>
12-
getEnvUniversal("RIVET_RUNNER_KEY") ?? crypto.randomUUID(),
13-
),
10+
.optional()
11+
.transform((x) => x ?? getEnvUniversal("RIVET_RUNNER_KEY")),
1412

1513
/** How many actors this runner can run. */
1614
totalSlots: z.number().default(100_000),

rivetkit-typescript/packages/rivetkit/src/manager/router.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ function addServerlessRoutes(
186186
newRunConfig.totalSlots = totalSlots;
187187
newRunConfig.runnerName = runnerName;
188188
newRunConfig.namespace = namespace;
189+
if (newRunConfig.runnerKey) {
190+
logger().warn({
191+
msg: "runner keys are not supported by serverless runners, this will be overwritten with a random runner key",
192+
oldRunnerKey: newRunConfig.runnerKey,
193+
});
194+
newRunConfig.runnerKey = undefined;
195+
}
189196

190197
// Create new actor driver with updated config
191198
const actorDriver = driverConfig.actor(

0 commit comments

Comments
 (0)