Compare commits

...

2 Commits

Author SHA1 Message Date
github-actions[bot] a62971c3c1 publish new versions 2026-06-29 09:01:45 +00:00
Bajoca d157387722 fix(single-instance): Yield unix listener in macos (#3466)
* Use tokio UnixListener so the task can yield and release the thread

* use standard unix listener, convert to non blocking and cast into tokio yielding one

* Create fix-yield-single-instance-macos.md

* Update .changes/fix-yield-single-instance-macos.md

Co-authored-by: Fabian-Lars <30730186+FabianLars@users.noreply.github.com>

* use net feature in Tokio dependency

* Use tokio UnixListener::bind, inside the tokio task

---------

Co-authored-by: Fabian-Lars <30730186+FabianLars@users.noreply.github.com>
2026-06-29 11:00:59 +02:00
17 changed files with 71 additions and 63 deletions
-6
View File
@@ -1,6 +0,0 @@
---
"log": minor:feat
"log-js": minor
---
Added the `FileOpenStrategy` for log rotation. It defaults to append into existing file if any (previous behaviour), and brings a new feature to create a new file per session: `FileOpenStrategy::Rotate`.
@@ -1,6 +0,0 @@
---
positioner: patch
positioner-js: patch
---
Replaced a panic in `calculate_position` with an error return when the window has no associated monitor (e.g. during display sleep or monitor reconfiguration).
-6
View File
@@ -1,6 +0,0 @@
---
"log": patch
"log-js": patch
---
Removed an unused dependency `byte-unit`.
Generated
+5 -4
View File
@@ -207,7 +207,7 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
[[package]] [[package]]
name = "api" name = "api"
version = "2.0.44" version = "2.0.45"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",
@@ -6643,7 +6643,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-log" name = "tauri-plugin-log"
version = "2.8.0" version = "2.9.0"
dependencies = [ dependencies = [
"android_logger", "android_logger",
"fern", "fern",
@@ -6745,7 +6745,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-positioner" name = "tauri-plugin-positioner"
version = "2.3.2" version = "2.3.3"
dependencies = [ dependencies = [
"log", "log",
"serde", "serde",
@@ -6785,7 +6785,7 @@ dependencies = [
[[package]] [[package]]
name = "tauri-plugin-single-instance" name = "tauri-plugin-single-instance"
version = "2.4.2" version = "2.4.3"
dependencies = [ dependencies = [
"semver", "semver",
"serde", "serde",
@@ -6793,6 +6793,7 @@ dependencies = [
"tauri", "tauri",
"tauri-plugin-deep-link", "tauri-plugin-deep-link",
"thiserror 2.0.12", "thiserror 2.0.12",
"tokio",
"tracing", "tracing",
"windows-sys 0.60.2", "windows-sys 0.60.2",
"zbus", "zbus",
+6
View File
@@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.41]
### Dependencies
- Upgraded to `log-js@2.9.0`
## \[2.0.40] ## \[2.0.40]
### Dependencies ### Dependencies
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "api", "name": "api",
"private": true, "private": true,
"version": "2.0.40", "version": "2.0.41",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite --clearScreen false", "dev": "vite --clearScreen false",
+6
View File
@@ -1,5 +1,11 @@
# Changelog # Changelog
## \[2.0.45]
### Dependencies
- Upgraded to `log@2.9.0`
## \[2.0.44] ## \[2.0.44]
### Dependencies ### Dependencies
+2 -2
View File
@@ -1,7 +1,7 @@
[package] [package]
name = "api" name = "api"
publish = false publish = false
version = "2.0.44" version = "2.0.45"
description = "An example Tauri Application showcasing the api" description = "An example Tauri Application showcasing the api"
edition = "2021" edition = "2021"
rust-version = { workspace = true } rust-version = { workspace = true }
@@ -20,7 +20,7 @@ serde = { workspace = true }
tiny_http = "0.12" tiny_http = "0.12"
time = "0.3" time = "0.3"
log = { workspace = true } log = { workspace = true }
tauri-plugin-log = { path = "../../../plugins/log", version = "2.8.0" } tauri-plugin-log = { path = "../../../plugins/log", version = "2.9.0" }
tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.5.1", features = [ tauri-plugin-fs = { path = "../../../plugins/fs", version = "2.5.1", features = [
"watch", "watch",
] } ] }
+5
View File
@@ -1,5 +1,10 @@
# Changelog # Changelog
## \[2.9.0]
- [`f08980f1`](https://github.com/tauri-apps/plugins-workspace/commit/f08980f123f191b9505bd290acd8fff0fdefeed9) ([#3445](https://github.com/tauri-apps/plugins-workspace/pull/3445) by [@bajoca05](https://github.com/tauri-apps/plugins-workspace/../../bajoca05)) Added the `FileOpenStrategy` for log rotation. It defaults to append into existing file if any (previous behaviour), and brings a new feature to create a new file per session: `FileOpenStrategy::Rotate`.
- [`0c23b8ec`](https://github.com/tauri-apps/plugins-workspace/commit/0c23b8ecfe7c2aca582a81ab7339b11e350b3cac) ([#3446](https://github.com/tauri-apps/plugins-workspace/pull/3446) by [@fee1-dead](https://github.com/tauri-apps/plugins-workspace/../../fee1-dead)) Removed an unused dependency `byte-unit`.
## \[2.8.0] ## \[2.8.0]
- [`2a625adf`](https://github.com/tauri-apps/plugins-workspace/commit/2a625adff30238904035b86b6e2db7595597e857) ([#3065](https://github.com/tauri-apps/plugins-workspace/pull/3065) by [@BinaryMuse](https://github.com/tauri-apps/plugins-workspace/../../BinaryMuse)) Allow specifying a log formatter per target using the `format` method on `Target`. - [`2a625adf`](https://github.com/tauri-apps/plugins-workspace/commit/2a625adff30238904035b86b6e2db7595597e857) ([#3065](https://github.com/tauri-apps/plugins-workspace/pull/3065) by [@BinaryMuse](https://github.com/tauri-apps/plugins-workspace/../../BinaryMuse)) Allow specifying a log formatter per target using the `format` method on `Target`.
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-log" name = "tauri-plugin-log"
version = "2.8.0" version = "2.9.0"
description = "Configurable logging for your Tauri app." description = "Configurable logging for your Tauri app."
authors = { workspace = true } authors = { workspace = true }
license = { workspace = true } license = { workspace = true }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@tauri-apps/plugin-log", "name": "@tauri-apps/plugin-log",
"version": "2.8.0", "version": "2.9.0",
"description": "Configurable logging for your Tauri app.", "description": "Configurable logging for your Tauri app.",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"authors": [ "authors": [
+4
View File
@@ -1,5 +1,9 @@
# Changelog # Changelog
## \[2.3.3]
- [`4be76900`](https://github.com/tauri-apps/plugins-workspace/commit/4be76900854cae3dc91363dea71b54505896e928) ([#3449](https://github.com/tauri-apps/plugins-workspace/pull/3449) by [@skkap](https://github.com/tauri-apps/plugins-workspace/../../skkap)) Replaced a panic in `calculate_position` with an error return when the window has no associated monitor (e.g. during display sleep or monitor reconfiguration).
## \[2.3.2] ## \[2.3.2]
- [`c0d64bf7`](https://github.com/tauri-apps/plugins-workspace/commit/c0d64bf7d9c0f2c8ed1d2614745e15bbb3cde6a7) ([#3420](https://github.com/tauri-apps/plugins-workspace/pull/3420) by [@UrsDeSwardt](https://github.com/tauri-apps/plugins-workspace/../../UrsDeSwardt)) Removed panics and replaced them with error handling. - [`c0d64bf7`](https://github.com/tauri-apps/plugins-workspace/commit/c0d64bf7d9c0f2c8ed1d2614745e15bbb3cde6a7) ([#3420](https://github.com/tauri-apps/plugins-workspace/pull/3420) by [@UrsDeSwardt](https://github.com/tauri-apps/plugins-workspace/../../UrsDeSwardt)) Removed panics and replaced them with error handling.
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-positioner" name = "tauri-plugin-positioner"
version = "2.3.2" version = "2.3.3"
description = "Position your windows at well-known locations." description = "Position your windows at well-known locations."
authors = { workspace = true } authors = { workspace = true }
license = { workspace = true } license = { workspace = true }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@tauri-apps/plugin-positioner", "name": "@tauri-apps/plugin-positioner",
"version": "2.3.2", "version": "2.3.3",
"description": "Position your windows at well-known locations.", "description": "Position your windows at well-known locations.",
"license": "MIT OR Apache-2.0", "license": "MIT OR Apache-2.0",
"authors": [ "authors": [
+4
View File
@@ -1,5 +1,9 @@
# Changelog # Changelog
## \[2.4.3]
- [`d1573877`](https://github.com/tauri-apps/plugins-workspace/commit/d1573877226e609461761aa538cd0ca4f24d22be) ([#3466](https://github.com/tauri-apps/plugins-workspace/pull/3466) by [@bajoca05](https://github.com/tauri-apps/plugins-workspace/../../bajoca05)) Fix blocked thread on the single-instance plugin for MacOS: replace standard `UnixListener` with `tokio::net::UnixListener`, so the task can yield.
## \[2.4.2] ## \[2.4.2]
### Dependencies ### Dependencies
+2 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "tauri-plugin-single-instance" name = "tauri-plugin-single-instance"
version = "2.4.2" version = "2.4.3"
description = "Ensure a single instance of your tauri app is running." description = "Ensure a single instance of your tauri app is running."
authors = { workspace = true } authors = { workspace = true }
license = { workspace = true } license = { workspace = true }
@@ -24,6 +24,7 @@ tracing = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tauri-plugin-deep-link = { path = "../deep-link", version = "2.4.9", optional = true } tauri-plugin-deep-link = { path = "../deep-link", version = "2.4.9", optional = true }
semver = { version = "1", optional = true } semver = { version = "1", optional = true }
tokio = { version = "1", features = ["net"] }
[target."cfg(target_os = \"windows\")".dependencies.windows-sys] [target."cfg(target_os = \"windows\")".dependencies.windows-sys]
version = "0.60" version = "0.60"
@@ -3,8 +3,8 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use std::{ use std::{
io::{BufWriter, Error, ErrorKind, Read, Write}, io::{BufWriter, Error, ErrorKind, Write},
os::unix::net::{UnixListener, UnixStream}, os::unix::net::UnixStream,
path::PathBuf, path::PathBuf,
}; };
@@ -15,6 +15,7 @@ use tauri::{
plugin::{self, TauriPlugin}, plugin::{self, TauriPlugin},
AppHandle, Config, Manager, RunEvent, Runtime, AppHandle, Config, Manager, RunEvent, Runtime,
}; };
use tokio::io::AsyncReadExt;
pub fn init<R: Runtime>(cb: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> { pub fn init<R: Runtime>(cb: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
plugin::Builder::new("single-instance") plugin::Builder::new("single-instance")
@@ -31,7 +32,7 @@ pub fn init<R: Runtime>(cb: Box<SingleInstanceCallback<R>>) -> TauriPlugin<R> {
ErrorKind::NotFound | ErrorKind::ConnectionRefused => { ErrorKind::NotFound | ErrorKind::ConnectionRefused => {
// This process claims itself as singleton as likely none exists // This process claims itself as singleton as likely none exists
socket_cleanup(&socket); socket_cleanup(&socket);
listen_for_other_instances(&socket, app.clone(), cb); listen_for_other_instances(socket, app.clone(), cb);
} }
_ => { _ => {
tracing::debug!( tracing::debug!(
@@ -92,42 +93,40 @@ fn notify_singleton(socket: &PathBuf) -> Result<(), Error> {
} }
fn listen_for_other_instances<A: Runtime>( fn listen_for_other_instances<A: Runtime>(
socket: &PathBuf, socket: PathBuf,
app: AppHandle<A>, app: AppHandle<A>,
mut cb: Box<SingleInstanceCallback<A>>, mut cb: Box<SingleInstanceCallback<A>>,
) { ) {
match UnixListener::bind(socket) { tauri::async_runtime::spawn(async move {
Ok(listener) => { match tokio::net::UnixListener::bind(socket) {
tauri::async_runtime::spawn(async move { Ok(listener) => loop {
for stream in listener.incoming() { match listener.accept().await {
match stream { Ok((mut stream, _addr)) => {
Ok(mut stream) => { let mut s = String::new();
let mut s = String::new(); match stream.read_to_string(&mut s).await {
match stream.read_to_string(&mut s) { Ok(_) => {
Ok(_) => { let (cwd, args) = s.split_once("\0\0").unwrap_or_default();
let (cwd, args) = s.split_once("\0\0").unwrap_or_default(); let args: Vec<String> =
let args: Vec<String> = args.split('\0').map(String::from).collect();
args.split('\0').map(String::from).collect(); cb(app.app_handle(), args, cwd.to_string());
cb(app.app_handle(), args, cwd.to_string()); }
} Err(e) => {
Err(e) => { tracing::debug!("single_instance failed to be notified: {e}")
tracing::debug!("single_instance failed to be notified: {e}")
}
} }
} }
Err(err) => { }
tracing::debug!("single_instance failed to be notified: {}", err); Err(err) => {
continue; tracing::debug!("single_instance failed to be notified: {}", err);
} continue;
} }
} }
}); },
Err(err) => {
tracing::error!(
"single_instance failed to listen to other processes - launching normally: {}",
err
);
}
} }
Err(err) => { });
tracing::error!(
"single_instance failed to listen to other processes - launching normally: {}",
err
);
}
}
} }