-
Notifications
You must be signed in to change notification settings - Fork 129
fix(rivetkit): fix duplicate runner key in serverless #3366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rivetkit): fix duplicate runner key in serverless #3366
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Code ReviewThis PR fixes duplicate runner key issues in serverless mode. The changes are well-targeted and solve the problem correctly. Here's my detailed review: ✅ Positive Aspects
🔍 Observations
🧪 Testing ConsiderationsConsider adding/verifying:
📝 Minor Suggestions
✅ Overall AssessmentApproval: The core fix is solid and addresses the duplicate runner key issue properly. The serverless-specific handling is appropriate and well-documented through logging. The changes follow TypeScript/Zod best practices and maintain backward compatibility while fixing the bug. The separation between config transformation and runtime fallback is cleaner than before. Rating: Looks good to merge (pending the minor cleanup of line 95 if desired) |
ad9c895 to
c017146
Compare
Code ReviewSummaryThis PR fixes an issue where duplicate runner keys were being used in serverless environments. The fix ensures each serverless runner gets a unique random UUID, preventing runner conflicts. Changes Analysis1. File:
2. File:
3. File:
Strengths
SuggestionsMinor: Code clarityIn // Line 95 - redundant assignment
const token = runConfig.token ?? runConfig.token;This appears to be leftover from a previous refactor (similar to the ones fixed in this PR). Should be: const token = runConfig.token;Minor: Type safety considerationThe runnerKey: z
.string()
.optional()
.transform((x) => x ?? getEnvUniversal("RIVET_RUNNER_KEY")), // Returns string | undefined - callers must provide fallbackTesting: Missing test coverageThere are no tests verifying the serverless runner key behavior. Consider adding a test that:
Example test location: Create a test in the driver test suite or add to router tests. Potential IssuesNone identified - The changes are safe and well-contained. Security ConsiderationsNo concerns - Using Performance ConsiderationsNo impact - UUID generation is negligible overhead during runner initialization. Verdict✅ LGTM with minor suggestions The fix correctly addresses the duplicate runner key issue in serverless environments. The code changes are clean, logical, and maintain backward compatibility. The suggestions above are minor improvements that could be addressed in follow-up PRs. Great work on identifying and fixing this subtle but important bug! |
c017146 to
e106dbd
Compare
3ed0d9f to
61bc452
Compare
Code ReviewSummaryThis PR fixes an issue where duplicate runner keys were being used in serverless mode, ensuring that serverless runners always get unique runner keys. The changes are focused and address the specific issue. Positive Observations
Issues & Concerns1. Redundant Code Removed (Minor Fix Needed)In const token = runConfig.token ?? runConfig.token;This should just be: const token = runConfig.token;2. Schema Behavior Change (Potential Breaking Change)The config schema change has a subtle but important behavior difference: Before: runnerKey: z.string().default(() => getEnvUniversal("RIVET_RUNNER_KEY") ?? crypto.randomUUID())
After: runnerKey: z.string().optional().transform((x) => x ?? getEnvUniversal("RIVET_RUNNER_KEY"))
Issues:
Recommendation: Consider using runnerKey: z.string()
.optional()
.transform((x) => x || getEnvUniversal("RIVET_RUNNER_KEY") || undefined)Or document that the final UUID fallback intentionally happens in the driver constructor. 3. Type Safety ConcernAfter the schema change, 4. Missing Test CoverageThere don't appear to be any tests verifying:
Consider adding tests to prevent regression. Minor Observations
Performance & Security✅ No performance concerns RecommendationApprove with minor fixes suggested. The core logic is sound, but please:
📝 Reviewed with attention to the project's CLAUDE.md conventions |
Code ReviewThis PR fixes an issue where duplicate runner keys were being used in serverless mode. The changes are well-targeted and solve the problem correctly. ✅ Strengths
🔍 Issues Found1. Redundant Code Still PresentLocation: Issue: Similar redundant pattern still exists: const token = runConfig.token ?? runConfig.token;Fix: Should be: const token = runConfig.token;2. Schema Behavior ChangeLocation: Issue: The
Recommendation: Consider explicit handling: .transform((x) => (x && x.length > 0) ? x : getEnvUniversal("RIVET_RUNNER_KEY"))Or use 🧪 Test Coverage ConcernsNo tests found verifying:
Recommendation: Add test coverage for this functionality to prevent regression. 📝 Minor Suggestions
✅ Overall AssessmentVerdict: Approve with minor fixes recommended The core fix is solid and properly addresses the duplicate runner key issue in serverless environments. The separation between config transformation and runtime fallback is cleaner than before. Please address the redundant code at line 95 and consider adding test coverage. Security: ✅ No concerns - |
e106dbd to
733d8e5
Compare
Code ReviewThis PR fixes duplicate runner key issues in serverless mode and cleans up redundant fallback logic. Overall the changes look good, but I have some feedback on code quality and potential improvements. Positive Changes
Issues & Suggestions1. Code Quality: Logging Pattern (rivetkit-typescript/packages/rivetkit/src/manager/router.ts:190-193)The current logging doesn't follow the structured logging pattern mentioned in the codebase conventions. The log message should be lowercase and parameters should be structured separately: // Current
logger().warn({
msg: "runner keys are not supported by serverless runners, this will be overwritten with a random runner key",
oldRunnerKey: newRunConfig.runnerKey,
});
// Suggested
logger().warn({
oldRunnerKey: newRunConfig.runnerKey,
msg: "runner keys are not supported by serverless runners, will be overwritten with random key"
});Per CLAUDE.md: "Log messages should be lowercase unless mentioning specific code symbols." 2. Potential Bug: Environment Variable Priority (rivetkit-typescript/packages/rivetkit/src/drivers/engine/config.ts:8-11)The new transform logic may have unexpected behavior: runnerKey: z
.string()
.optional()
.transform((x) => x ?? getEnvUniversal("RIVET_RUNNER_KEY")),Issue: This will return Consideration: Should the environment variable be checked before the transform, or is the current behavior intentional? The old code had the UUID generation in the schema itself. 3. Missing Test CoverageI notice there are no tests covering:
Recommendation: Add tests to verify:
4. Consistency with Cloudflare WorkersI notice that inputConfig = { ...inputConfig, runnerKey: "" };Question: Should serverless runners use the same pattern (empty string) instead of Security ConsiderationsNo security concerns identified. The use of Performance ConsiderationsThe changes have minimal performance impact. The only addition is the warning log for serverless runners, which is appropriate. SummaryApprove with minor suggestions. The core fix is solid and addresses the duplicate runner key issue. The main recommendations are:
The PR can be merged after addressing the logging pattern issue. |
733d8e5 to
ef42842
Compare
PR Review: fix(rivetkit): fix duplicate runner key in serverlessSummaryThis PR fixes issues with the
Code Quality ✅Positive Changes:
Potential Issues 🔍1. Breaking Behavior Change (Minor)
This should be fine, but the logic could be clearer. Currently:
2. Type Safety Consideration 3. Serverless Override Logic logger().warn({
msg: "runner keys are not supported by serverless runners, using a random runner key instead",
oldRunnerKey: newRunConfig.runnerKey,
});Performance ✅No performance concerns - the changes are minimal and don't introduce any new expensive operations. Security ✅No security concerns. The change from predictable environment-based keys to random UUIDs for serverless runners actually improves isolation. Test Coverage
|
ef42842 to
3763786
Compare
5d31632 to
422a612
Compare
PR Review: Fix duplicate runner key in serverlessSummaryThis PR fixes a bug where redundant null-coalescing operators ( Code Quality ✅Positive Changes:
Code Style:
Logic & Implementation ✅config.ts changes:
actor-driver.ts changes:
router.ts changes:
Potential Concerns
|
Merge activity
|

No description provided.