Răsfoiți Sursa

Log every error in websocker worker

Cesar Rodas 3 luni în urmă
părinte
comite
392136e6df
1 a modificat fișierele cu 20 adăugiri și 18 ștergeri
  1. 20 18
      crates/cdk/src/wallet/subscription/ws.rs

+ 20 - 18
crates/cdk/src/wallet/subscription/ws.rs

@@ -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);