Skip to content

fix(rivetkit): isolate engine envoys and propagate startup failures#4643

Draft
NathanFlurry wants to merge 1 commit intotest/remove-wasm-sqlite-fixturesfrom
fix/isolate-engine-envoys
Draft

fix(rivetkit): isolate engine envoys and propagate startup failures#4643
NathanFlurry wants to merge 1 commit intotest/remove-wasm-sqlite-fixturesfrom
fix/isolate-engine-envoys

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

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 13, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 13, 2026

PR Review: fix(rivetkit): isolate engine envoys and propagate startup failures

This is a focused, well-scoped fix addressing two related issues: envoy singleton reuse across drivers and silent startup failure swallowing.


What this PR does

  1. Envoy isolation - Prevents EngineActorDriver instances from sharing a global singleton envoy handle. Without this, multiple drivers in the same process silently reuse the first driver connection regardless of config.
  2. Startup failure propagation - Changes started() from async fn started returning void (errors silently swallowed) to returning anyhow::Result<()>, threading the error through the N-API bridge and into TypeScript via .reject(error).

Issues

Medium: start_envoy panics on startup failure instead of returning Result

Per CLAUDE.md conventions, failable functions should return anyhow::Result and use .context() rather than .expect(). A panic here is not recoverable and bypasses the error propagation the rest of this PR correctly establishes. Suggested fix: change the return type to anyhow::Result and replace .expect() with .context("envoy failed to start")?.

Minor: Prefer .context() over anyhow::anyhow!()

CLAUDE.md states: prefer .context() over the anyhow! macro. The .map_err call in handle.rs can be replaced with .context("envoy stopped before startup completed")?.


Positive observations

  • notGlobal: true is the highest-impact change, correctly scopes envoy handles to each driver instance.
  • TypeScript rejection path in actor-driver.ts is now correct; the previous .then callback with no rejection handler silently dropped startup errors.
  • N-API bridge in envoy_handle.rs correctly chains .map_err() to surface Rust errors to JS as napi::Error.
  • No usage of rivet.gg, forbidden concurrency primitives, println or eprintln macros, or Mutex over HashMap.

@NathanFlurry NathanFlurry force-pushed the test/remove-wasm-sqlite-fixtures branch from ada1fe0 to dbb2ed4 Compare April 13, 2026 21:07
@NathanFlurry NathanFlurry force-pushed the fix/isolate-engine-envoys branch from 8786de2 to b2d071c Compare April 13, 2026 21:07
@NathanFlurry NathanFlurry mentioned this pull request Apr 13, 2026
11 tasks
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