Fix sidecar stdout buffering: set PYTHONUNBUFFERED=1
All checks were successful
Release / Run Tests (push) Successful in 24s
Tests / Python Backend Tests (push) Successful in 5s
Tests / Frontend Tests (push) Successful in 7s
Tests / Rust Sidecar Tests (push) Successful in 3m17s
Release / Bump version and tag (push) Successful in 4s

PyInstaller frozen executables buffer stdout when piped to a
subprocess (no TTY). Even with flush=True in Python, the OS-level
pipe buffer can delay output. This prevented the ready event from
reaching the Tauri app, causing the "Starting sidecar..." hang.

Fix: set PYTHONUNBUFFERED=1 env var on both prod and dev sidecar
commands, plus -u flag for dev mode Python.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Developer
2026-04-07 12:17:09 -07:00
parent 08e464daaf
commit 18e6b974c0

View File

@@ -555,7 +555,7 @@ impl SidecarManager {
fn build_dev_command(&self) -> Result<std::process::Command, String> {
let mut cmd = std::process::Command::new("python");
cmd.args(["-m", "backend.main_headless"]);
cmd.args(["-u", "-m", "backend.main_headless"]); // -u = unbuffered
// Try to find the project root (parent of src-tauri)
if let Some(dirs) = DIRS.get() {
@@ -568,6 +568,7 @@ impl SidecarManager {
}
}
cmd.env("PYTHONUNBUFFERED", "1");
Ok(cmd)
}
@@ -583,6 +584,9 @@ impl SidecarManager {
bin.parent()
.ok_or("Cannot determine sidecar parent dir")?,
);
// Force unbuffered stdout so the ready event is sent immediately.
// PyInstaller frozen executables buffer stdout when piped.
cmd.env("PYTHONUNBUFFERED", "1");
Ok(cmd)
}