diff --git a/libsql/src/database.rs b/libsql/src/database.rs index da0cc7dfac..a583c6a652 100644 --- a/libsql/src/database.rs +++ b/libsql/src/database.rs @@ -682,17 +682,20 @@ impl Database { }; use tokio::sync::Mutex; - let _ = tokio::task::block_in_place(move || { - let rt = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build() - .unwrap(); - rt.block_on(async { + if let Some(sync_ctx) = &db.sync_ctx { + let sync_ctx_clone = sync_ctx.clone(); + std::thread::spawn(move || { + let rt = tokio::runtime::Runtime::new().unwrap(); // we will ignore if any errors occurred during the bootstrapping the db, // because the client could be offline when trying to connect. - let _ = db.bootstrap_db().await; + rt.block_on(async { + let mut locked_ctx = sync_ctx_clone.lock().await; + let _ = crate::sync::bootstrap_db(&mut locked_ctx).await; + }); }) - }); + .join() + .expect("thread panicked while bootstrapping the db"); + } let local = db.connect()?;