-
Notifications
You must be signed in to change notification settings - Fork 130
fix(rivetkit): fix initial hibernation state always being overridden with msgIndex of -1 #3389
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
Conversation
…with msgIndex of -1
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
Code ReviewSummaryThis PR fixes a critical bug where existing hibernatable WebSocket state was being overridden with a new entry having Positive Aspects✅ Correct Bug Fix: The core issue is properly addressed. Previously, even when ✅ Good Logging: Added structured debug logs that will help trace WebSocket hibernation behavior:
✅ Follows Logging Conventions: Properly uses structured logging with the ✅ Preserves State Correctly: The fix ensures that Issues & Suggestions1. Race Condition Risk (Minor)The code directly mutates 2. Missing Test Coverage (Important)This is a bug fix for critical state management logic, but there don't appear to be tests for WebSocket hibernation scenarios. Consider adding tests that verify:
The rivetkit-typescript codebase has a driver test suite at 3. Code Clarity (Minor)The condition at line 264-280 now has two branches doing different operations. Consider adding a comment explaining why we update vs. create: // Save or update hibernatable WebSocket
// If this WebSocket already exists (reconnection), only update the timestamp
// to preserve the msgIndex state. Otherwise, create a new entry.
if (existingWs) {
// ...Performance Considerations✅ No performance concerns. The changes are minimal and don't introduce additional iterations or allocations. Security Considerations✅ No security concerns identified. The fix properly handles state management without exposing any security risks. RecommendationsHigh Priority:
Low Priority:
ConclusionThis is a solid bug fix that addresses a real state management issue. The logic is correct and the logging additions will aid debugging. The main gap is test coverage to ensure this behavior doesn't regress in the future. Approval: ✅ Approved with the suggestion to add tests in a follow-up PR. |
More templates
@rivetkit/actor
@rivetkit/cloudflare-workers
@rivetkit/core
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
Merge activity
|
…with msgIndex of -1 (#3389)

No description provided.