Skip to content

fix(rivetkit): expose client actor metadata#5016

Draft
NathanFlurry wants to merge 1 commit into
counter-latency/unbounded-dispatch-channelsfrom
counter-latency/client-protocol-polish
Draft

fix(rivetkit): expose client actor metadata#5016
NathanFlurry wants to merge 1 commit into
counter-latency/unbounded-dispatch-channelsfrom
counter-latency/client-protocol-polish

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 11, 2026

Code Review: fix(rivetkit): expose client actor metadata

Overview

This PR makes three related changes:

  1. Adds a CLAUDE.md note documenting the client/server protocol compatibility assumption (server >= client)
  2. Adds the actor specifier object (actorId, generation, key) to the AsyncAPI error message schemas
  3. Pre-populates #actorId in ActorConnRaw's constructor when using a getForId resolution state, so the ID is available immediately rather than waiting for the WebSocket Init message

Code Quality

actor-conn.ts constructor change (lines 219-221)

The early pre-population is simple and correct. This is a minor ergonomic improvement - callers using getForId no longer have to wait for the Init message before reading actorId.

#clearResolvedActorIdentity interaction

Pre-existing issue (fine to defer): #clearResolvedActorIdentity() sets #actorId = undefined on reconnects. For getForId connections the actor ID is statically known, so clearing it means the ID briefly becomes undefined between reconnects until the new Init message arrives. Since the getter is documented @internal, this is low risk, but it would be cleaner to skip the clear for getForId connections.


Test Coverage

Missing coverage for the new code path

The new test uses getOrCreate, which exercises the WebSocket Init message path (existing behavior). The new constructor code only runs for getForId queries - that path has no test coverage in this PR. Consider adding a test that:

  1. Resolves an actor ID via getOrCreate
  2. Creates a getForId handle and calls .connect()
  3. Asserts that connection.actorId is set before connection.ready resolves

Existing test - ordering note

connection.actorId is captured synchronously on the left side of toBe before handle.resolve() is awaited. This is correct and intentional.


AsyncAPI Schema

generation type uses dual anyOf

The schema uses anyOf: [number, integer/int64]. The number arm allows floats. If generation is always integral, using only integer/int64 would be more precise. If the dual-type is required for BigInt/JS-number interop, a short note explaining why would help.

actor optionality is correct

actor is correctly absent from the required array in both error schema locations, matching the existing TypeScript ActorSpecifier? optional type.

Both schema locations updated

The PR updates both the inline WebSocket Error tag schema and the standalone ActionErrorResponse component. Both should stay in sync. Correct.


CLAUDE.md

The added protocol compatibility note is clear and useful. Minor: it sits in the vbare section rather than a dedicated protocol section, but the topic is close enough to fit.


Summary

Area Status
Core logic Correct
getForId constructor path test coverage Missing
AsyncAPI schema correctness Looks good (minor: generation float question)
Reconnect / #clearResolvedActorIdentity gap Pre-existing, worth a follow-up
CLAUDE.md note Good

The main actionable ask is a test that verifies actorId is non-null before connection.ready resolves when connecting via getForId. Everything else is minor.

@MasterPtato MasterPtato force-pushed the counter-latency/unbounded-dispatch-channels branch from 9c656c0 to a499917 Compare May 14, 2026 17:26
@MasterPtato MasterPtato force-pushed the counter-latency/client-protocol-polish branch from ec783c3 to 6127de0 Compare May 14, 2026 17:26
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.

1 participant