Skip to content

Serverless listener forwards /start to the application when basePath is "/" #5755

Description

What happens

With serverless.basePath: "/" and an application passed to registry.listen(), the Rust listener forwards the engine's POST /start to the application instead of handling it. Same for /health, /metadata and /metrics. Actors on that pool never start. The same config works through registry.handler().

Where

handles_listener_request in rivetkit-rust/packages/rivetkit-core/src/serverless.rs:

let request_path = parsed.path();
if request_path != base_path && !request_path.starts_with(&format!("{base_path}/")) {
	return false;
}

Why it happens

normalize_base_path(Some("/")) returns "/", so the prefix check looks for "//". No request path starts with //, so everything except / itself returns false. serverless_http.rs only hands a request to the runtime when this returns true or when there's no application, so /start ends up in the user's handler.

route_path already handles a root base path correctly. It's only this check. The TypeScript side special-cases it in isServerlessStartRequest (basePath === "/" ? "" : ...), which is why registry.handler() works.

Reproduction

Add to rivetkit-rust/packages/rivetkit-core/tests/serverless.rs:

#[test]
fn listener_reserves_framework_routes_for_root_base_path() {
	let base_path = normalize_base_path(Some("/"));
	for path in ["/", "/start", "/health", "/metadata", "/metrics"] {
		assert!(
			handles_listener_request(&base_path, &format!("http://internal{path}")),
			"root base path should reserve {path}"
		);
	}
	assert!(!handles_listener_request(&base_path, "http://internal/application"));
}

cargo test -p rivetkit-core --lib listener_reserves_framework_routes_for_root_base_path fails with root base path should reserve /start.

Expected behaviour

With a root base path the listener handles /, /start, /health, /metadata and /metrics itself and forwards everything else to the application.

Suggested fix

Treat base_path == "/" as matching every request path before the prefix check. route_path already returns the right route in that case. Happy to open a PR.

Environment

  • upstream/main at 78336a1a0
  • Linux 7.2.5-3-omarchy
  • rustc 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1 (797e8a9bc 2026-08-05)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions