From 7f65305fb8deeade563ff9873fb8dca72a6cf3a8 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sun, 15 Feb 2026 12:18:02 +0100 Subject: [PATCH] Fix exec_streaming blocking: run channel.exec() before switching to non-blocking mode Co-Authored-By: Claude Opus 4.6 --- crates/vm-manager/src/ssh.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/crates/vm-manager/src/ssh.rs b/crates/vm-manager/src/ssh.rs index 3f13818..1d51603 100644 --- a/crates/vm-manager/src/ssh.rs +++ b/crates/vm-manager/src/ssh.rs @@ -104,16 +104,13 @@ pub fn exec_streaming( detail: format!("channel session: {e}"), })?; - // Non-blocking mode so we can interleave stdout and stderr reads - sess.set_blocking(false); - - channel.exec(cmd).map_err(|e| { - sess.set_blocking(true); - VmError::SshFailed { - detail: format!("exec '{cmd}': {e}"), - } + channel.exec(cmd).map_err(|e| VmError::SshFailed { + detail: format!("exec '{cmd}': {e}"), })?; + // Switch to non-blocking after exec so we can interleave stdout and stderr reads + sess.set_blocking(false); + let mut stdout_buf = Vec::new(); let mut stderr_buf = Vec::new(); let mut buf = [0u8; 8192];