Skip to content

Commit b9c06b2

Browse files
committed
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
1 parent 7cc36cc commit b9c06b2

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

examples/helloworld/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"tauri": "tauri"
1212
},
1313
"dependencies": {
14-
"@tauri-apps/api": "^2.1.1",
14+
"@tauri-apps/api": "^2.7.0",
1515
"@aptabase/tauri": "file:../../"
1616
},
1717
"devDependencies": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"typescript": "^5.7.2"
3737
},
3838
"dependencies": {
39-
"@tauri-apps/api": "^2.1.1",
39+
"@tauri-apps/api": "^2.7.0",
4040
"tslib": "^2.8.1"
4141
}
4242
}

src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl AptabaseClient {
7575
pub(crate) fn start_polling(&self, interval: Duration) {
7676
let dispatcher = self.dispatcher.clone();
7777

78-
tokio::spawn(async move {
78+
tauri::async_runtime::spawn(async move {
7979
loop {
8080
tokio::time::sleep(interval).await;
8181
dispatcher.flush().await;

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod config;
44
mod dispatcher;
55
mod sys;
66

7-
use std::{panic::PanicInfo, sync::Arc, time::Duration};
7+
use std::{panic::PanicHookInfo, sync::Arc, time::Duration};
88

99
use client::AptabaseClient;
1010
use config::Config;
@@ -28,9 +28,9 @@ pub struct Builder {
2828
}
2929

3030
pub type PanicHook =
31-
Box<dyn Fn(&AptabaseClient, &PanicInfo<'_>, String) + 'static + Sync + Send>;
31+
Box<dyn Fn(&AptabaseClient, &PanicHookInfo<'_>, String) + 'static + Sync + Send>;
3232

33-
fn get_panic_message(info: &PanicInfo) -> String {
33+
fn get_panic_message(info: &PanicHookInfo) -> String {
3434
let payload = info.payload();
3535
if let Some(s) = payload.downcast_ref::<&str>() {
3636
return s.to_string();

0 commit comments

Comments
 (0)