You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
PR Review: feat(rivetkit): allow configuring runtime mode via env
Overall this is a clean, well-scoped addition that is consistent with existing codebase patterns. A few gaps worth addressing before merge.
Strengths
Pattern consistency — getRivetRuntimeMode in env-vars.ts follows exactly the same shape as every other env-var accessor in that file.
Correct precedence — config.mode is checked first; envRuntimeMode is only consulted when config.mode === undefined, preventing the env var from silently overriding deliberate programmatic config.
Schema reuse — RuntimeModeSchema.safeParse(...) avoids duplicating the enum allowlist and correctly wires the error into Zod's issue context.
Docs updated — the IMPORTANT header comment in env-vars.ts requires updating the docs page, and the PR does that correctly.
Issues / Gaps
1. Missing test: RIVET_RUNTIME_MODE=envoy with no endpoint
When RIVET_RUNTIME_MODE=envoy is set but no endpoint is configured, the existing path that fires "Rivet endpoint is required when startEngine is false" will trigger. There's already a test for the code-configured path ("explicit envoy mode requires an endpoint"), but no parallel test for the env-var path. This scenario is easy to hit by accident in a misconfigured deployment and should be covered.
2. Missing test: RIVET_RUNTIME_MODE=serverless with a valid endpoint
There's a test confirming RIVET_RUNTIME_MODE=envoy sets envoy mode, but no symmetric test for serverless. Adding it would mirror the existing pattern (e.g. "configured endpoints default to serverless" vs "explicit envoy mode disables local engine startup").
3. Confusing test setup in "explicit mode overrides RIVET_RUNTIME_MODE"
The test sets RIVET_RUNTIME_MODE=local (an invalid value) alongside mode: "envoy". The test passes because when config.mode !== undefined the env var is never parsed — so the invalid value is silently ignored rather than rejected. This is correct behavior, but a reader might not realize why it's using an intentionally invalid value. A one-line comment explaining it (e.g. // Use an invalid env value to confirm it is skipped entirely when config.mode is set) would prevent confusion.
Minor Nits
The doc comment on the mode field ("Can also be set via RIVET_RUNTIME_MODE.") is consistent with how endpoint is documented. No issue.
No performance or security concerns — env var is read once at parse time, invalid values are rejected via Zod before any runtime behavior changes.
Summary
The three test cases that do exist cover the core scenarios (env override, explicit wins, invalid value rejected). Adding the two missing cases and a clarifying comment would make this complete. No bugs or design issues found.
All packages published as 0.0.0-pr.4866.1b9199c with tag pr-4866.
Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: