-
Notifications
You must be signed in to change notification settings - Fork 76
fix(retry): always retry connection for receiver stream #447
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
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modifies the retry logic in the FlashblocksReceiverService to ensure continuous reconnection attempts, even in unexpected scenarios where the connection handling completes successfully.
Key Changes:
- Changed from
if let Errpattern that would break the loop onOk(())to amatchstatement that handles both error and success cases - Added defensive
unwrap_or_elsefor backoff interval to handle the theoretical case where backoff returnsNone - Added explicit handling for the unexpected
Ok(())case with immediate reconnection and logging
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Flashblocks receiver connection ended unexpectedly with Ok(()), this should never happen. Reconnecting immediately." | ||
| ); | ||
| self.metrics.reconnect_attempts.increment(1); | ||
| self.metrics.connection_status.set(0); |
Copilot
AI
Nov 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider resetting the backoff in the Ok(()) branch to ensure clean state for the next reconnection attempt. Even though this case should never happen, if it does occur after several failed attempts with exponential backoff, the next error would use an inflated backoff interval.
Ok(()) => {
// This should never happen - connect_and_handle should loop forever
// or return an error. If we get here, reconnect immediately.
error!(
"Flashblocks receiver connection ended unexpectedly with Ok(()), this should never happen. Reconnecting immediately."
);
self.metrics.reconnect_attempts.increment(1);
self.metrics.connection_status.set(0);
backoff.reset(); // Reset backoff for clean state
// Reconnect immediately without delay since this is unexpected
}| self.metrics.connection_status.set(0); | |
| self.metrics.connection_status.set(0); | |
| backoff.reset(); // Reset backoff for clean state |
| tokio::time::sleep(interval).await; | ||
| } else { | ||
| break; | ||
| match self.connect_and_handle(&mut backoff).await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 changes were made here:
- remove the break part, we expect the receiver to always run unless the service gets shutdown
- Added some logging to help triage problems if it came up again.
No description provided.