Skip to content

Commit

Permalink
Log every error in websocker worker
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Dec 5, 2024
1 parent 2c3b683 commit 392136e
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions crates/cdk/src/wallet/subscription/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,27 @@ pub async fn ws_main(

loop {
tracing::debug!("Connecting to {}", url);
let (ws_stream, _) = if let Ok(result) = connect_async(&url).await {
result
} else {
failure_count += 1;
if failure_count > MAX_ATTEMPT_FALLBACK_HTTP {
tracing::error!(
"Could not connect to server after {MAX_ATTEMPT_FALLBACK_HTTP} attempts, falling back to HTTP-subscription client"
);
return fallback_to_http(
active_subscriptions.into_keys(),
http_client,
mint_url,
subscriptions,
new_subscription_recv,
on_drop,
)
.await;
let ws_stream = match connect_async(&url).await {
Ok((ws_stream, _)) => ws_stream,
Err(err) => {
failure_count += 1;
tracing::error!("Could not connect to server: {:?}", err);
if failure_count > MAX_ATTEMPT_FALLBACK_HTTP {
tracing::error!(
"Could not connect to server after {MAX_ATTEMPT_FALLBACK_HTTP} attempts, falling back to HTTP-subscription client"
);
return fallback_to_http(
active_subscriptions.into_keys(),
http_client,
mint_url,
subscriptions,
new_subscription_recv,
on_drop,
)
.await;
}
continue;
}
continue;
};
tracing::debug!("Connected to {}", url);

Expand Down

0 comments on commit 392136e

Please sign in to comment.