From ddaee1f5ce3d628311824ea87800e6d3afa4752c Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sat, 28 Nov 2026 11:03:31 +0800 Subject: [PATCH] fix(host): keep a command's last output lines after it exits (#6625) run_command stopped reading a finished command's output after 100 ms without a line, so on a busy machine the last lines (often the error a failed worktree setup script printed) were lost. It now reads until the pipes close, for at most a second. Sibling output loops already wait for the pipes to close. --- crates/ide-host/src/environment.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/ide-host/src/environment.rs b/crates/ide-host/src/environment.rs index 9dfa6f0ed1..d83563755d 100644 --- a/crates/ide-host/src/environment.rs +++ b/crates/ide-host/src/environment.rs @@ -420,12 +420,11 @@ pub(crate) fn run_command( } // A process it started in the background may keep the pipes open: the command is done. if let Some(status) = child.try_wait().map_err(|e| e.to_string())? { + // Read what it wrote until the pipes close, for at most a second: a busy machine may + // deliver its last lines (often the error) well after the exit. let deadline = Instant::now() + Duration::from_secs(1); - while let Ok(line) = rx.recv_timeout(Duration::from_millis(100)) { + while let Ok(line) = rx.recv_timeout(deadline.saturating_duration_since(Instant::now())) { on_line(line); - if Instant::now() > deadline { - break; - } } break status; }