fix: PTY crash — use std:🧵:spawn instead of tokio::spawn_blocking
All checks were successful
Build & Sign Wraith / Build Windows + Sign (push) Successful in 2m49s

tokio::task::spawn_blocking panics when called without a tokio runtime
context. Sync Tauri command handlers may not have one. The PTY reader
loop is long-lived anyway — std:🧵:spawn is more correct for
persistent blocking I/O and doesn't require a runtime guard.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-24 21:13:42 -04:00
parent 512347af5f
commit 37c9b46a51

View File

@ -112,11 +112,13 @@ impl PtyService {
self.sessions.insert(session_id.clone(), session);
// Output reader loop — runs in a blocking thread because
// portable-pty's reader is synchronous (std::io::Read).
// Output reader loop — runs in a dedicated OS thread because
// portable-pty's reader is synchronous (std::io::Read) and
// long-lived. Using std::thread::spawn avoids requiring a
// tokio runtime context (sync Tauri commands may not have one).
let sid = session_id.clone();
let app = app_handle;
tokio::task::spawn_blocking(move || {
std::thread::spawn(move || {
let mut reader = std::io::BufReader::new(reader);
let mut buf = [0u8; 4096];
loop {