From 21b87f6af540f340f8126e2df81082476407615c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Tue, 5 Jul 2022 20:22:22 +0200 Subject: [PATCH] nym-connect: fix catching panic in init --- nym-connect/src-tauri/src/config/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/nym-connect/src-tauri/src/config/mod.rs b/nym-connect/src-tauri/src/config/mod.rs index cda081175f..8a88b65037 100644 --- a/nym-connect/src-tauri/src/config/mod.rs +++ b/nym-connect/src-tauri/src/config/mod.rs @@ -84,10 +84,13 @@ impl Config { // The client initialization was originally not written for this use case, so there are // lots of ways it can panic. Until we have proper error handling in the init code for the - // clients we'll catch any panics here. - std::panic::catch_unwind(move || { - futures::executor::block_on(init_socks5(service_provider, chosen_gateway_id)); + // clients we'll catch any panics here by spawning a new runtime in a separate thread. + std::thread::spawn(move || { + tokio::runtime::Runtime::new() + .expect("Failed to create tokio runtime") + .block_on(async move { init_socks5(service_provider, chosen_gateway_id).await }) }) + .join() .map_err(|_| BackendError::InitializationPanic)?; info!("Configuration saved 🚀");