Skip to content

Commit e106dbd

Browse files
committed
fix(rivetkit): fix duplicate runner key in serverless
1 parent 61bc452 commit e106dbd

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ export class EngineActorDriver implements ActorDriver {
109109
version: this.#version,
110110
endpoint: getEndpoint(runConfig),
111111
token,
112-
namespace: runConfig.namespace ?? runConfig.namespace,
113-
totalSlots: runConfig.totalSlots ?? runConfig.totalSlots,
114-
runnerName: runConfig.runnerName ?? runConfig.runnerName,
115-
runnerKey: runConfig.runnerKey,
112+
namespace: runConfig.namespace,
113+
totalSlots: runConfig.totalSlots,
114+
runnerName: runConfig.runnerName,
115+
runnerKey: runConfig.runnerKey ?? crypto.randomUUID(),
116116
metadata: {
117117
inspectorToken: this.#runConfig.inspector.token(),
118118
},

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)