From b9c06b29c74bb47678e883c393d238cc7ca2fdd5 Mon Sep 17 00:00:00 2001 From: Alex Zappa Date: Sun, 8 Feb 2026 23:28:01 +0100 Subject: [PATCH] fix: resolve tokio runtime panic and update deprecated API - Replace tokio::spawn with tauri::async_runtime::spawn to fix panic when called outside of Tokio runtime context - Update deprecated PanicInfo to PanicHookInfo - Bump @tauri-apps/api to ^2.7.0 for IPC fix Fixes #22 Fixes #25 --- examples/helloworld/package.json | 2 +- package.json | 2 +- src/client.rs | 2 +- src/lib.rs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/helloworld/package.json b/examples/helloworld/package.json index 2c6fd20..8720e00 100644 --- a/examples/helloworld/package.json +++ b/examples/helloworld/package.json @@ -11,7 +11,7 @@ "tauri": "tauri" }, "dependencies": { - "@tauri-apps/api": "^2.1.1", + "@tauri-apps/api": "^2.7.0", "@aptabase/tauri": "file:../../" }, "devDependencies": { diff --git a/package.json b/package.json index 2c16439..ff0a2f6 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "typescript": "^5.7.2" }, "dependencies": { - "@tauri-apps/api": "^2.1.1", + "@tauri-apps/api": "^2.7.0", "tslib": "^2.8.1" } } diff --git a/src/client.rs b/src/client.rs index da9d905..5a2ffd7 100644 --- a/src/client.rs +++ b/src/client.rs @@ -75,7 +75,7 @@ impl AptabaseClient { pub(crate) fn start_polling(&self, interval: Duration) { let dispatcher = self.dispatcher.clone(); - tokio::spawn(async move { + tauri::async_runtime::spawn(async move { loop { tokio::time::sleep(interval).await; dispatcher.flush().await; diff --git a/src/lib.rs b/src/lib.rs index a2b747c..824a794 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ mod config; mod dispatcher; mod sys; -use std::{panic::PanicInfo, sync::Arc, time::Duration}; +use std::{panic::PanicHookInfo, sync::Arc, time::Duration}; use client::AptabaseClient; use config::Config; @@ -28,9 +28,9 @@ pub struct Builder { } pub type PanicHook = - Box, String) + 'static + Sync + Send>; + Box, String) + 'static + Sync + Send>; -fn get_panic_message(info: &PanicInfo) -> String { +fn get_panic_message(info: &PanicHookInfo) -> String { let payload = info.payload(); if let Some(s) = payload.downcast_ref::<&str>() { return s.to_string();