Skip to content

fix(engine-runner): terminate requests for missing actors - #5573

Open
Sms1818 wants to merge 1 commit into
rivet-dev:mainfrom
Sms1818:fix/engine-runner-missing-actor-request
Open

fix(engine-runner): terminate requests for missing actors#5573
Sms1818 wants to merge 1 commit into
rivet-dev:mainfrom
Sms1818:fix/engine-runner-missing-actor-request

Conversation

@Sms1818

@Sms1818 Sms1818 commented Aug 18, 2026

Copy link
Copy Markdown

Fixes a request leak in the TypeScript engine runner when a request arrives for an actor that is no longer loaded.

Previously, #handleRequestStart() logged that the request would leak and returned without sending a terminal response. This left the gateway waiting for a response until its response-start timeout.

The runner now sends a retryable 503 Service Unavailable response with the x-rivet-error: runner.actor_not_found header when the actor cannot be found. This follows the existing missing-actor retry semantics used elsewhere in the runner and allows Guard to retry the request instead of waiting for the timeout.

A regression test was added to verify that requests for unloaded actors receive the expected terminal response.

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?

Added a focused regression test covering a ToClientRequestStart received for an unloaded actor.

Verified with:

  • pnpm exec vitest run tests/tunnel-missing-actor.test.ts
  • pnpm --filter @rivetkit/engine-runner check-types
  • pnpm --filter @rivetkit/engine-runner build
  • git diff --check

The regression test verifies that the runner returns:

  • HTTP status 503
  • x-rivet-error: runner.actor_not_found
  • the expected response body and content length
  • a terminal non-streaming response

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

Copilot AI lite review requested due to automatic review settings August 18, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a request leak in the TypeScript engine runner tunnel path by ensuring that a ToClientRequestStart for an actor that is no longer loaded receives a terminal response (instead of returning early and leaving the gateway to time out). This aligns the tunnel behavior with the existing missing-actor retry semantics already present in the runner’s fetch path.

Changes:

  • Update Tunnel.#handleRequestStart() to send a retryable 503 response with x-rivet-error: runner.actor_not_found when getAndWaitForActor() returns no actor.
  • Add a regression test verifying that missing-actor tunnel requests receive the expected non-streaming terminal response.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rivetkit-typescript/packages/engine-runner/src/tunnel.ts Sends a terminal 503 + x-rivet-error: runner.actor_not_found response when a request arrives for an unloaded actor.
rivetkit-typescript/packages/engine-runner/tests/tunnel-missing-actor.test.ts Adds a focused regression test for the missing-actor tunnel request response semantics.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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