Skip to content

Commit db6cfaa

Browse files
committed
fix: reconnection to FB logic
1 parent adbe143 commit db6cfaa

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/robust_provider/subscription.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,6 @@ impl<N: Network> RobustSubscription<N> {
8383
"Subscription timeout - no block received, switching provider"
8484
);
8585

86-
// If we're on a fallback, force reconnect to primary
87-
// before switching to the next fallback (bypassing reconnect interval)
88-
if self.current_fallback_index.is_some() &&
89-
self.try_reconnect_to_primary(true).await
90-
{
91-
continue;
92-
}
93-
9486
self.switch_to_fallback(elapsed_err.into()).await?;
9587
}
9688
}
@@ -169,6 +161,11 @@ impl<N: Network> RobustSubscription<N> {
169161
}
170162

171163
async fn switch_to_fallback(&mut self, last_error: Error) -> Result<(), Error> {
164+
// If we're on a fallback, try primary first before moving to next fallback
165+
if self.current_fallback_index.is_some() && self.try_reconnect_to_primary(true).await {
166+
return Ok(());
167+
}
168+
172169
if self.last_reconnect_attempt.is_none() {
173170
self.last_reconnect_attempt = Some(Instant::now());
174171
}

0 commit comments

Comments
 (0)