Skip to content

fix(rivetkit): spawn the local Engine on the endpoint's port - #5643

Open
eersnington wants to merge 1 commit into
rivet-dev:mainfrom
eersnington:stack/fix-rivetkit-preserve-engine-bind-defaults-rqsvztrk
Open

fix(rivetkit): spawn the local Engine on the endpoint's port#5643
eersnington wants to merge 1 commit into
rivet-dev:mainfrom
eersnington:stack/fix-rivetkit-preserve-engine-bind-defaults-rqsvztrk

Conversation

@eersnington

@eersnington eersnington commented Sep 2, 2026

Copy link
Copy Markdown

Description

If you set endpoint to a local URL, RivetKit still spawned the Engine on port 6420. So the client waited on the port you asked for, and the health check failed.

endpoint: "http://127.0.0.1:54250"
├── client waits on    :54250
└── Engine listens on  :6420   <- hard-coded default

The fix: engineHost and enginePort stay unset unless you set them, so the Engine falls back to the endpoint's port.

  • Nothing set: still 6420. Unchanged.
  • Explicit enginePort: used as before. Unchanged.
  • Only an endpoint: the Engine now listens on that endpoint's port. This never worked before.

This only affects local dev and tests. Deployed apps never spawn an Engine.

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?

# Before, RivetKit asked for port 54250:

$ pnpm exec vitest run tests/napi-runtime-integration.test.ts
target=rivetkit_napi::registry message="serving native registry" endpoint=http://127.0.0.1:54250/
target=rivetkit_engine_process message="spawned engine process (intentionally orphaned, will outlive this process)" pid=11147
[Error: {"code":"health_check_failed","group":"engine","message":"Engine health check failed after 14 attempts: error sending request for url (http://127.0.0.1:54250/health)"}]
 × native NAPI runtime integration > runs a TS actor through registry, NAPI, core, envoy, and engine

# The Engine's own log from that run shows where it bound:

 message="loaded config" config="Root { ... guard: Some(Guard { host: Some(127.0.0.1), port: Some(6420), ...
 message="HTTP server listening on 127.0.0.1:6420"

# After:

$ pnpm exec vitest run tests/napi-runtime-integration.test.ts
 ✓ native NAPI runtime integration > runs a TS actor through registry, NAPI, core, envoy, and engine  6825ms
 Test Files  1 passed (1)

message="loaded config" config="Root { ... guard: Some(Guard { host: Some(127.0.0.1), port: Some(54308), ...
message="HTTP server listening on 127.0.0.1:54308"

# Also:

$ pnpm exec vitest run tests/registry-constructor.test.ts
 Tests  6 passed (6)

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

@eersnington
eersnington force-pushed the stack/fix-rivetkit-preserve-engine-bind-defaults-rqsvztrk branch from c1f2e1f to 2b600fd Compare September 2, 2026 21:15
@eersnington eersnington changed the title fix(rivetkit): preserve engine bind defaults fix(rivetkit): spawn the local Engine on the endpoint's port Sep 11, 2026
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