fix: use tauri::async_runtime::spawn for WAL checkpoint task
tokio::spawn() panics during Tauri setup in WebDriver E2E mode because the Tokio runtime is not directly accessible. Switch to tauri::async_runtime::spawn() which uses Tauri's managed runtime.
This commit is contained in:
parent
2aec5889f8
commit
661f092fb2
1 changed files with 3 additions and 1 deletions
|
|
@ -123,8 +123,10 @@ pub(crate) fn checkpoint_wal(path: &Path) -> Result<(), String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spawn a background task that checkpoints WAL on both databases every 5 minutes.
|
/// Spawn a background task that checkpoints WAL on both databases every 5 minutes.
|
||||||
|
/// Uses `tauri::async_runtime::spawn` instead of `tokio::spawn` because this runs
|
||||||
|
/// during Tauri setup where the Tokio runtime may not be directly accessible.
|
||||||
fn spawn_wal_checkpoint_task(sessions_db_path: PathBuf, btmsg_db_path: PathBuf) {
|
fn spawn_wal_checkpoint_task(sessions_db_path: PathBuf, btmsg_db_path: PathBuf) {
|
||||||
tokio::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
let interval = std::time::Duration::from_secs(300);
|
let interval = std::time::Duration::from_secs(300);
|
||||||
loop {
|
loop {
|
||||||
tokio::time::sleep(interval).await;
|
tokio::time::sleep(interval).await;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue