nym-connect: fix catching panic in init

This commit is contained in:
Jon Häggblad
2022-07-05 20:22:22 +02:00
parent fe59697aa9
commit 21b87f6af5
+6 -3
View File
@@ -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 🚀");