-
Notifications
You must be signed in to change notification settings - Fork 150
fix(rivetkit): shorten local dev client retry backoff #4062
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
base: main
Are you sure you want to change the base?
Conversation
- Add isLocalDev() helper that checks NODE_ENV on server, hostname on browser - Reduce retry intervals to fixed 1s in local dev (was exponential 250ms-30s) - Affects actor-conn.ts reconnects and metadata.ts polling - Production backoff behavior unchanged
Code Review: Fix Local Dev Client Retry BackoffOverviewThis PR improves the local development experience by reducing retry backoff intervals from exponential (250ms-30s) to a fixed 1s delay. The changes are well-scoped and address a real DX pain point. Positive Aspects ✅
Issues & Suggestions🔴 Critical: Environment Detection Logic IssueLocation: The export const isLocalDev = (): boolean => {
if (typeof window \!== "undefined") {
const hostname = window?.location?.hostname;
if (hostname) {
return (
hostname === "localhost" ||
hostname === "127.0.0.1" ||
hostname === "::1" ||
hostname === "[::1]"
);
}
}
return isDev();
};Problem: When running in a browser but Recommendation: export const isLocalDev = (): boolean => {
if (typeof window \!== "undefined") {
const hostname = window?.location?.hostname;
if (hostname) {
return (
hostname === "localhost" ||
hostname === "127.0.0.1" ||
hostname === "::1" ||
hostname === "[::1]"
);
}
// In browser but no hostname - assume production
return false;
}
// Server-side: check NODE_ENV
return isDev();
};🟡 Minor: Optional Chaining RedundancyLocation: const hostname = window?.location?.hostname;The 🟡 Minor: IPv6 Hostname VariationsLocation: Consider additional IPv6 variations that might be encountered:
However, this is probably over-engineering for a local dev detection helper. The current implementation covers the most common cases. 🟢 Code StyleThe code follows TypeScript conventions well. However, per CLAUDE.md:
Testing ConsiderationsMissing Test Coverage: There are no tests for the new
Manual Testing Checklist:
Performance & SecurityPerformance: ✅ No concerns. The Security: ✅ No security concerns. The retry timing changes don't introduce vulnerabilities. Recommendations Summary
VerdictThe PR addresses a real DX issue with a pragmatic solution. With the critical logic fix applied, this is ready to merge. The changes are low-risk since they only affect local development behavior. Suggested Action: Request changes to fix the |
Problem
Client uses extensive exponential backoff in local development, which is frustrating when iterating quickly.
Solution
isLocalDev()helper inenv-vars.ts:NODE_ENV !== 'production'Changes
rivetkit-typescript/packages/rivetkit/src/utils/env-vars.ts- newisLocalDev()helperrivetkit-typescript/packages/rivetkit/src/client/actor-conn.ts- use fixed 1s retries in local devrivetkit-typescript/packages/rivetkit/src/remote-manager-driver/metadata.ts- use fixed 1s retries in local dev