I'm migrating to Tauri and coming across an error while setting up the database within tauri::Builder.
This is the error I get: thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6er47d384he001f/tokio-1.43.0/src/runtime/scheduler/multi_thread/mod.rs:86:9:
Cannot start a runtime from within a runtime. This happens because a function (like block_on) attempted to block the current thread while the thread is being used to drive asynchronous tasks.
Should I jsut remove tokio::main or just set up the database differently? Appreciate the help. I also included main.rs which has the full code
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![])
.setup(move |app| {
tauri::async_runtime::block_on(async move { //This gives me an error
let db = setup_db(&app).await;
app.manage(AppState { db });
});
tauri::async_runtime::spawn(async move { axum::serve(listener, start_app) });
Ok(())
})
.run(tauri::generate_context!())
.expect("Error while running tauri application");