summaryrefslogtreecommitdiff
path: root/lib/hyperstack/state.rb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-25 21:26:31 +0300
committerPaul Buetow <paul@buetow.org>2026-05-25 21:26:31 +0300
commit578b0f747d8cf773c0e5ba9394bcf8436d6b0a01 (patch)
tree066f52745e761f76b0cd8eca9f1add47843b432b /lib/hyperstack/state.rb
parentc315cc0d9a89984ea43a6f7f59f0e5cd9560e7c9 (diff)
fix(prefixed_output): add flush to prevent losing final unterminated line
PrefixedOutput#print buffers partial lines until a newline is received. When the last chunk from a stream does not end with \n (common with Open3 popen2e EOF), that chunk was discarded. Add #flush to emit the remaining buffer with the prefix, and call it at the end of all streaming loops in SshRunner and WireGuardSetup.
Diffstat (limited to 'lib/hyperstack/state.rb')
-rw-r--r--lib/hyperstack/state.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/hyperstack/state.rb b/lib/hyperstack/state.rb
index 0ce2687..a52b057 100644
--- a/lib/hyperstack/state.rb
+++ b/lib/hyperstack/state.rb
@@ -53,5 +53,12 @@ module HyperstackVM
@mutex.synchronize { @delegate.print("#{@prefix}#{line}") }
end
end
+
+ def flush
+ return if @buffer.empty?
+
+ @mutex.synchronize { @delegate.print("#{@prefix}#{@buffer}") }
+ @buffer = +''
+ end
end
end