guest-agent: stream non-TTY exec output as it is produced - #490
Open
palashswapnil wants to merge 1 commit into
Open
palashswapnil wants to merge 1 commit into
palashswapnil wants to merge 1 commit into
Conversation
Buffering stdout/stderr until exit stalls long-lived commands (relays, tails). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chruffins
self-requested a review
October 2, 2026 18:42
Contributor
|
hey! this seems like a straightforward improvement but I'm confused by your use case for this. is this for a project that you're using hypeman for? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
executeNoTTYreads stdout and stderr withio.ReadAlland sends nothing until the process exits. Any long-running non-TTY exec therefore delivers no output while it runs:tail -f/instances/{id}/exec)This showed up while using exec as a TCP relay for CDP and WebRTC to browser instances. HTTP/1.0 requests worked, because the server closes the connection and the relay exits. Keep-alive and WebSocket traffic hung forever.
Fix
Pump stdout and stderr concurrently, sending each chunk as it is read (up to 32 KiB, as before). Both pipes are still fully drained before
cmd.Wait(), and the exit code is still sent last. The TTY path already streams this way.One behaviour change: stdout and stderr chunks may now interleave in the order they are produced, instead of all stdout followed by all stderr.
Tests
TestExecuteNoTTYStreamsOutputBeforeExitrunsecho first; sleep 2; echo secondand asserts the first chunk arrives well before exit. It fails onmain("first chunk arrived at 2.003s but command exited at 2.004s") and passes with this change.go test ./lib/system/guest_agent/passes (linux/arm64, golang:1.25)./instances/{id}/execnow stream. That covered CDP keep-alive and WebSocket traffic, plus neko WebRTC over ICE-TCP, across a fleet of 7 instances.🤖 Generated with Claude Code