fix: prevent daemon panic on broken stderr pipe during Chrome launch (#802)
Replace all `eprintln!` calls in daemon-context code with `let _ = writeln!(std::io::stderr(), ...)` so that broken pipe errors on stderr are silently ignored instead of panicking. The CLI client spawns the daemon with piped stderr to capture startup errors, then drops the pipe handle once the daemon is ready. Any subsequent `eprintln!` in the daemon panics because Rust's `eprintln!` macro internally unwraps the write result. This caused the reported "failed printing to stderr: Broken pipe (os error 32)" panic during Chrome launch on Linux. Closes #799 Co-authored-by: ctate <366502+ctate@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::time::Duration;
|
||||
@@ -47,7 +47,10 @@ impl Drop for ChromeProcess {
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!(
|
||||
// Use write! instead of eprintln! to avoid panicking
|
||||
// if the daemon's stderr pipe is broken (parent dropped it).
|
||||
let _ = writeln!(
|
||||
std::io::stderr(),
|
||||
"Warning: failed to clean up temp profile {}: {}",
|
||||
dir.display(),
|
||||
e
|
||||
@@ -207,9 +210,13 @@ pub fn launch_chrome(options: &LaunchOptions) -> Result<ChromeProcess, String> {
|
||||
Err(e) => {
|
||||
last_err = e;
|
||||
if attempt < max_attempts {
|
||||
eprintln!(
|
||||
// Use write! instead of eprintln! to avoid panicking
|
||||
// if the daemon's stderr pipe is broken (parent dropped it).
|
||||
let _ = writeln!(
|
||||
std::io::stderr(),
|
||||
"[chrome] Launch attempt {}/{} failed, retrying in 500ms...",
|
||||
attempt, max_attempts
|
||||
attempt,
|
||||
max_attempts
|
||||
);
|
||||
std::thread::sleep(Duration::from_millis(500));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user