From 6a89fffeac3537170e547ecc5fa47932c849b185 Mon Sep 17 00:00:00 2001 From: godmodegalactus Date: Sun, 7 Jan 2024 16:42:59 +0100 Subject: [PATCH] Reconnecting instead of panicing for some cases --- src/grpc_subscription_autoreconnect.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/grpc_subscription_autoreconnect.rs b/src/grpc_subscription_autoreconnect.rs index 4a2f864..be6aa1e 100644 --- a/src/grpc_subscription_autoreconnect.rs +++ b/src/grpc_subscription_autoreconnect.rs @@ -141,10 +141,11 @@ fn map_commitment_level(commitment_config: CommitmentConfig) -> CommitmentLevel yellowstone_grpc_proto::prelude::CommitmentLevel::Finalized } _ => { - panic!( - "unsupported commitment level {}", + log::error!( + "unsupported commitment level {}, defaulting to finalized", commitment_config.commitment - ) + ); + yellowstone_grpc_proto::prelude::CommitmentLevel::Finalized } } } @@ -214,7 +215,8 @@ pub fn create_geyser_reconnecting_stream( (ConnectionState::WaitReconnect(attempt), Message::Connecting(attempt)) }, Err(geyser_grpc_task_error) => { - panic!("! task aborted - should not happen :{geyser_grpc_task_error}"); + warn!("task aborted reconnect error: {}", geyser_grpc_task_error); + (ConnectionState::WaitReconnect(attempt), Message::Connecting(attempt)) } } @@ -234,7 +236,9 @@ pub fn create_geyser_reconnecting_stream( } None => { // should not arrive here, Mean the stream close. - panic!("geyser stream closed on {} - retrying", grpc_source); + // reconnect + warn!("task aborted reconnect"); + (ConnectionState::WaitReconnect(attempt), Message::Connecting(attempt)) } }