Skip to content

feat: dynamic actors#4395

Open
NathanFlurry wants to merge 9 commits intomainfrom
feat/dynamic-actors
Open

feat: dynamic actors#4395
NathanFlurry wants to merge 9 commits intomainfrom
feat/dynamic-actors

Conversation

@NathanFlurry
Copy link
Member

Summary

  • Dynamic actors: load and run actor code at runtime from arbitrary sources
  • Hibernatable WebSocket improvements
  • Engine driver enhancements

Test plan

  • Existing driver test suite passes
  • pkg.pr.new publishes successfully

🤖 Generated with Claude Code

@railway-app
Copy link

railway-app bot commented Mar 10, 2026

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

Service Status Web Updated (UTC)
frontend-inspector ❌ Build Failed (View Logs) Web Mar 10, 2026 at 3:56 pm
website ❌ Build Failed (View Logs) Web Mar 10, 2026 at 3:55 pm
mcp-hub ✅ Success (View Logs) Web Mar 10, 2026 at 3:54 pm
ladle ❌ Build Failed (View Logs) Web Mar 10, 2026 at 3:54 pm
frontend-cloud ❌ Build Failed (View Logs) Web Mar 10, 2026 at 3:54 pm

@claude
Copy link

claude bot commented Mar 10, 2026

PR Review: feat: dynamic actors

This is a substantial PR adding dynamic actor support — loading and running actor code at runtime from arbitrary sources inside sandboxed isolates. Overall the design is solid and well-documented. A few issues worth addressing before merge.

Bugs / Issues

Typo in NodeProcessLike interface (isolate-runtime.ts)

__unsafeIsoalte should be __unsafeIsolate. This appears in both the interface definition and the usage site, so both need fixing.

Architecture doc contradicts the type definition

docs-internal/rivetkit-typescript/DYNAMIC_ACTORS_ARCHITECTURE.md step 4 says the default sourceFormat is "typescript" which gets transpiled, but DynamicSourceFormat in runtime-bridge.ts is only "commonjs-js" | "esm-js" — there is no "typescript" variant. Meanwhile internal.ts comments say sourceFormat defaults to "esm-js". The architecture doc should describe the actual behavior (unset → transpiled to CommonJS).

Commented-out code left in example (examples/dynamic-actors/src/actors.ts, lines ~57–85)

There is a large block of commented-out code with a // // === separator showing an alternative fetch-based loader pattern. This should be removed or extracted to a separate dedicated example before merging.

Minor Issues

#hibernatableWebSocketAckObservers cleanup in sleep path (global-state.ts)

The map is declared and register/unregister methods exist, but no cleanup of this map is visible in the actor sleep path. The destroy path cleans up #dynamicRuntimes and #actorInitialInputs, but #hibernatableWebSocketAckObservers entries could accumulate if the unregister call-sites do not cover all exit paths.

any types in DynamicActorDefinition constructor (internal.ts)

The ActorConfigSchema.parse() call and subsequent casts use several layers of any. This is contained within internal.ts and not exposed publicly, so not critical, but worth noting.

Positives

  • Gateway race condition fix: The pending_msgs VecDeque to buffer runner messages during the WebSocket open handshake elegantly fixes a real race condition without restructuring the task loop.
  • Runner stale-socket guard (mod.ts): The if (ws !== this.#pegboardWebSocket) check and the try/catch wrapper around the entire message handler are solid defensive improvements.
  • Empty catch {} replacement: Several empty catch blocks now log at debug level, consistent with project conventions.
  • Architecture doc: DYNAMIC_ACTORS_ARCHITECTURE.md is thorough and clearly describes the bridge contract, lifecycle, and security model.
  • Security model: Per-actor sandboxed NodeProcess with filesystem restricted to the actor runtime dir and read-only node_modules is a well-scoped isolation boundary.
  • Driver parity via static/dynamic fixture variants: Running the same test suite against both registry-static.ts and registry-dynamic.ts is a clean way to verify parity without duplicating test logic.

🤖 Generated with Claude Code

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