Skip to content

Conversation

@NathanFlurry
Copy link
Member

Summary

Allows specifying a runner per-call instead of only at client config level.

Usage

// getOrCreate with runner override
client.actor.getOrCreate(['key'], {
  createOnRunner: 'my-specific-runner'
});

// create with runner override
await client.actor.create(['key'], {
  runner: 'my-specific-runner'
});

Changes

  • client.ts: Add createOnRunner to GetOrCreateOptions, runner to CreateOptions
  • protocol/query.ts: Add runner field to CreateRequestSchema and GetOrCreateRequestSchema
  • driver.ts: Add runner to GetOrCreateWithKeyInput and CreateInput interfaces
  • actor-query.ts: Pass runner through to manager driver calls

Note

This adds the client-side support. The manager/engine implementation to actually route to the specified runner may need additional work depending on how runner selection is handled server-side.

Allows specifying a runner per-call instead of only at client config level.

Usage:
```ts
// getOrCreate with runner override
client.actor.getOrCreate(['key'], {
  createOnRunner: 'my-specific-runner'
});

// create with runner override
await client.actor.create(['key'], {
  runner: 'my-specific-runner'
});
```

Changes:
- client.ts: Add createOnRunner to GetOrCreateOptions, runner to CreateOptions
- protocol/query.ts: Add runner field to schemas
- driver.ts: Add runner to input interfaces
- actor-query.ts: Pass runner through to manager driver
@railway-app
Copy link

railway-app bot commented Jan 29, 2026

🚅 Deployed to the rivet-pr-4064 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Jan 29, 2026 at 1:01 pm
frontend-inspector 😴 Sleeping (View Logs) Web Jan 29, 2026 at 12:40 pm
website 😴 Sleeping (View Logs) Web Jan 29, 2026 at 12:38 pm
mcp-hub ✅ Success (View Logs) Web Jan 29, 2026 at 12:32 pm

@claude
Copy link

claude bot commented Jan 29, 2026

Code Review: feat(rivetkit): add runner override option to getOrCreate and create

Summary

This PR adds the ability to specify a runner on a per-call basis for getOrCreate and create operations, overriding the client's default runner configuration. The changes are well-structured and follow existing patterns in the codebase.

✅ Positives

  1. Consistent API Design: The parameter naming follows a good pattern:

    • createOnRunner for GetOrCreateOptions (matches createInRegion, createWithInput)
    • runner for CreateOptions (matches region, input)
  2. Type Safety: Proper Zod schema updates ensure runtime validation of the new runner field

  3. Clean Implementation: Changes are minimal and focused, touching only the necessary files

  4. Documentation: JSDoc comments clearly explain the purpose of the new parameters

🐛 Critical Issue: Missing Implementation in Remote Manager Driver

The PR has a critical bug where the runner parameter is not actually used in the remote-manager-driver.

Problem locations:

  • rivetkit-typescript/packages/rivetkit/src/remote-manager-driver/mod.ts:199 - uses this.#config.runnerName instead of runner parameter
  • rivetkit-typescript/packages/rivetkit/src/remote-manager-driver/mod.ts:235 - uses this.#config.runnerName instead of runner parameter

Current code:

// In getOrCreateWithKey (line 195-204)
const { actor, created } = await getOrCreateActor(this.#config, {
    datacenter: region,
    name,
    key: serializeActorKey(key),
    runner_name_selector: this.#config.runnerName,  // ❌ Wrong - ignores input.runner
    input: actorInput ? uint8ArrayToBase64(cbor.encode(actorInput)) : undefined,
    crash_policy: "sleep",
});

// In createActor (line 232-239)
const result = await createActor(this.#config, {
    datacenter: region,
    name,
    runner_name_selector: this.#config.runnerName,  // ❌ Wrong - ignores input.runner
    key: serializeActorKey(key),
    input: input ? uint8ArrayToBase64(cbor.encode(input)) : undefined,
    crash_policy: "sleep",
});

Fix needed:

// In getOrCreateWithKey
const { actor, created } = await getOrCreateActor(this.#config, {
    datacenter: region,
    name,
    key: serializeActorKey(key),
    runner_name_selector: runner ?? this.#config.runnerName,  // ✅ Use parameter or fall back to config
    input: actorInput ? uint8ArrayToBase64(cbor.encode(actorInput)) : undefined,
    crash_policy: "sleep",
});

// In createActor
const result = await createActor(this.#config, {
    datacenter: region,
    name,
    runner_name_selector: runner ?? this.#config.runnerName,  // ✅ Use parameter or fall back to config
    key: serializeActorKey(key),
    input: input ? uint8ArrayToBase64(cbor.encode(input)) : undefined,
    crash_policy: "sleep",
});

📝 Recommendations

  1. Fix the Remote Manager Driver: Update both getOrCreateWithKey and createActor methods to use the runner parameter with fallback to config (see fix above)

  2. Add Tests: Consider adding tests to verify:

    • Runner override works correctly when specified
    • Falls back to default runner when not specified
    • Integration test showing end-to-end runner selection
  3. Type Consistency: Consider extracting the destructured parameters to make the runner field explicit:

    async createActor({
        c,
        name,
        key,
        input,
        region,
        runner,  // Make it explicit in the destructure
    }: CreateInput): Promise<ActorOutput> {

🔒 Security

No security concerns identified. The runner parameter is validated by Zod schemas and follows the same pattern as other optional parameters.

⚡ Performance

No performance concerns. The changes add minimal overhead (one optional parameter check).

📊 Test Coverage

Missing: No tests were added for this new functionality. Suggest adding:

  • Unit tests for parameter passing through the client API
  • Integration tests verifying runner selection at the remote manager level

Verdict

Needs Changes - The PR introduces a valuable feature but has a critical implementation gap where the runner parameter is not actually used in the remote manager driver. Once fixed, this will be a solid addition to the API.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 29, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4064

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/db@4064

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4064

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4064

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4064

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4064

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4064

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4064

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4064

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4064

commit: 3aa3474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants