Skip to content

feat: spawn background stderr drain thread in SSH connection - #2912

Merged
oferchen merged 1 commit into
masterfrom
feat/ssh-stderr-drain
Mar 22, 2026
Merged

oferchen merged 1 commit into
masterfrom
feat/ssh-stderr-drain

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Spawn the SSH stderr drain thread at SshConnection construction time instead of deferring to split(), preventing pipe-buffer deadlocks when the remote rsync writes large error output to stderr before the connection is split
  • Collect stderr output into a bounded Arc<Mutex<Vec<u8>>> buffer (64 KB cap, oldest bytes discarded on overflow) while also forwarding lines to eprintln!
  • Add stderr_output() on both SshConnection and SshChildHandle for programmatic access to collected stderr
  • Add wait_with_stderr() on SshChildHandle for atomic exit-status + stderr retrieval after the handle is consumed
  • Remove stderr_mut() and take_stderr() which are incompatible with eager drain (no non-test callers existed)

Test plan

  • stderr_output_collected_via_child_handle - verifies stderr lines are captured and retrievable after wait
  • stderr_output_empty_when_no_errors - verifies empty buffer when child produces no stderr
  • stderr_output_bounded_to_cap - verifies 128 KB of stderr is truncated to 64 KB cap
  • stderr_output_readable_before_wait - verifies output is accessible via polling before child exits
  • Existing drain tests (stderr_drain_forwards_error_output_after_split, stderr_drain_handles_large_output_without_deadlock, stderr_drain_joins_on_drop, stderr_drain_with_no_stderr_output) continue to pass
  • CI: fmt+clippy, nextest (stable), Windows, macOS, Linux musl

@github-actions github-actions Bot added the enhancement New feature or request label Mar 21, 2026
@oferchen
oferchen force-pushed the feat/ssh-stderr-drain branch from 7b5013e to 6d46186 Compare March 22, 2026 06:55
@oferchen
oferchen merged commit 9d77bc0 into master Mar 22, 2026
30 of 31 checks passed
@oferchen
oferchen deleted the feat/ssh-stderr-drain branch March 22, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant