Repository navigation
feat(rsync_io): async stderr drain task for SSH socketpair (#2373) - #4363
Merged
Merged
Conversation
3 tasks done
oferchen
added a commit
that referenced
this pull request
May 18, 2026
SSE-6 from docs/design/socketpair-stderr-channel.md. Drives the SSE-3 `make_stderr_socketpair` primitive end-to-end by wiring the child end into a real subprocess as fd 2 and asserting the parent end surfaces the bytes verbatim. Each captured line additionally fires a `tracing::warn!` event, mirroring the production drain shape staged in SSE-4 (#4363) so this test continues to exercise the observable contract once the async path lands. Scenarios: - single_error_line_propagates_through_socketpair: one echo writes `test error message\n`; parent buffer matches byte-for-byte and a single WARN event fires with the captured payload. - multi_error_lines_propagate_and_fire_one_warn_each: three separate echo calls produce three ordered lines; all three are captured in order and one WARN event fires per line. - drain_returns_after_child_exit_closes_child_end: confirms the drain observes EOF cleanly when the subprocess exits and the child end closes, guarding the failure mode the design doc calls out under "Tokio drain task survives past child reap". Gated `cfg(all(unix, feature = "ssh-socketpair-stderr"))` so the file no-ops on Windows and on default builds. Adds `tracing` and `tracing-subscriber` as dev-dependencies of `rsync_io`; a custom `Layer` records WARN events with thread-local dispatch propagated to the spawned drain thread.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
SSE-6 from docs/design/socketpair-stderr-channel.md. Drives the SSE-3 `make_stderr_socketpair` primitive end-to-end by wiring the child end into a real subprocess as fd 2 and asserting the parent end surfaces the bytes verbatim. Each captured line additionally fires a `tracing::warn!` event, mirroring the production drain shape staged in SSE-4 (#4363) so this test continues to exercise the observable contract once the async path lands. Scenarios: - single_error_line_propagates_through_socketpair: one echo writes `test error message\n`; parent buffer matches byte-for-byte and a single WARN event fires with the captured payload. - multi_error_lines_propagate_and_fire_one_warn_each: three separate echo calls produce three ordered lines; all three are captured in order and one WARN event fires per line. - drain_returns_after_child_exit_closes_child_end: confirms the drain observes EOF cleanly when the subprocess exits and the child end closes, guarding the failure mode the design doc calls out under "Tokio drain task survives past child reap". Gated `cfg(all(unix, feature = "ssh-socketpair-stderr"))` so the file no-ops on Windows and on default builds. Adds `tracing` and `tracing-subscriber` as dev-dependencies of `rsync_io`; a custom `Layer` records WARN events with thread-local dispatch propagated to the spawned drain thread.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
SSE-6 from docs/design/socketpair-stderr-channel.md. Drives the SSE-3 `make_stderr_socketpair` primitive end-to-end by wiring the child end into a real subprocess as fd 2 and asserting the parent end surfaces the bytes verbatim. Each captured line additionally fires a `tracing::warn!` event, mirroring the production drain shape staged in SSE-4 (#4363) so this test continues to exercise the observable contract once the async path lands. Scenarios: - single_error_line_propagates_through_socketpair: one echo writes `test error message\n`; parent buffer matches byte-for-byte and a single WARN event fires with the captured payload. - multi_error_lines_propagate_and_fire_one_warn_each: three separate echo calls produce three ordered lines; all three are captured in order and one WARN event fires per line. - drain_returns_after_child_exit_closes_child_end: confirms the drain observes EOF cleanly when the subprocess exits and the child end closes, guarding the failure mode the design doc calls out under "Tokio drain task survives past child reap". Gated `cfg(all(unix, feature = "ssh-socketpair-stderr"))` so the file no-ops on Windows and on default builds. Adds `tracing` and `tracing-subscriber` as dev-dependencies of `rsync_io`; a custom `Layer` records WARN events with thread-local dispatch propagated to the spawned drain thread.
Implements SSE-4 from docs/design/socketpair-stderr-channel.md: when both async-ssh and ssh-socketpair-stderr features are enabled, AsyncSshTransport installs a socketpair-backed stderr channel and drains it via a tokio task into a bounded 8 KiB RingBuffer, emitting tracing::warn! per line. - New module async_stderr_drain.rs gated on both features - RingBuffer<const N: usize> with sliding-window semantics - AsyncStderrDrain::spawn(reader) wires a tokio::spawn drain loop - stderr_capture() snapshot accessor; join() awaits clean EOF - Drop aborts the task safely (it only owns reader + Arc buffer clone) - Wire into AsyncSshTransport::execute_remote_rsync: replace Stdio::inherit with configure_stderr_channel when both features are enabled on Unix; fall back to inherit on FD exhaustion per the design doc - AsyncSshTransport::stderr_capture() returns the bounded snapshot - Unit tests (Unix-only): 1 KiB write/snapshot equality, multi-line capture, clean EOF after sender drop, capture cap enforcement, ring buffer math # Conflicts: # crates/rsync_io/Cargo.toml
oferchen
force-pushed
the
feat/ssh-async-stderr-drain
branch
from
May 18, 2026 02:52
b5b6c97 to
9973edc
Compare
oferchen
added a commit
that referenced
this pull request
May 18, 2026
SSE-6 from docs/design/socketpair-stderr-channel.md. Drives the SSE-3 `make_stderr_socketpair` primitive end-to-end by wiring the child end into a real subprocess as fd 2 and asserting the parent end surfaces the bytes verbatim. Each captured line additionally fires a `tracing::warn!` event, mirroring the production drain shape staged in SSE-4 (#4363) so this test continues to exercise the observable contract once the async path lands. Scenarios: - single_error_line_propagates_through_socketpair: one echo writes `test error message\n`; parent buffer matches byte-for-byte and a single WARN event fires with the captured payload. - multi_error_lines_propagate_and_fire_one_warn_each: three separate echo calls produce three ordered lines; all three are captured in order and one WARN event fires per line. - drain_returns_after_child_exit_closes_child_end: confirms the drain observes EOF cleanly when the subprocess exits and the child end closes, guarding the failure mode the design doc calls out under "Tokio drain task survives past child reap". Gated `cfg(all(unix, feature = "ssh-socketpair-stderr"))` so the file no-ops on Windows and on default builds. Adds `tracing` and `tracing-subscriber` as dev-dependencies of `rsync_io`; a custom `Layer` records WARN events with thread-local dispatch propagated to the spawned drain thread.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…4363) Implements SSE-4 from docs/design/socketpair-stderr-channel.md: when both async-ssh and ssh-socketpair-stderr features are enabled, AsyncSshTransport installs a socketpair-backed stderr channel and drains it via a tokio task into a bounded 8 KiB RingBuffer, emitting tracing::warn! per line. - New module async_stderr_drain.rs gated on both features - RingBuffer<const N: usize> with sliding-window semantics - AsyncStderrDrain::spawn(reader) wires a tokio::spawn drain loop - stderr_capture() snapshot accessor; join() awaits clean EOF - Drop aborts the task safely (it only owns reader + Arc buffer clone) - Wire into AsyncSshTransport::execute_remote_rsync: replace Stdio::inherit with configure_stderr_channel when both features are enabled on Unix; fall back to inherit on FD exhaustion per the design doc - AsyncSshTransport::stderr_capture() returns the bounded snapshot - Unit tests (Unix-only): 1 KiB write/snapshot equality, multi-line capture, clean EOF after sender drop, capture cap enforcement, ring buffer math # Conflicts: # crates/rsync_io/Cargo.toml
oferchen
added a commit
that referenced
this pull request
May 18, 2026
SSE-6 from docs/design/socketpair-stderr-channel.md. Drives the SSE-3 `make_stderr_socketpair` primitive end-to-end by wiring the child end into a real subprocess as fd 2 and asserting the parent end surfaces the bytes verbatim. Each captured line additionally fires a `tracing::warn!` event, mirroring the production drain shape staged in SSE-4 (#4363) so this test continues to exercise the observable contract once the async path lands. Scenarios: - single_error_line_propagates_through_socketpair: one echo writes `test error message\n`; parent buffer matches byte-for-byte and a single WARN event fires with the captured payload. - multi_error_lines_propagate_and_fire_one_warn_each: three separate echo calls produce three ordered lines; all three are captured in order and one WARN event fires per line. - drain_returns_after_child_exit_closes_child_end: confirms the drain observes EOF cleanly when the subprocess exits and the child end closes, guarding the failure mode the design doc calls out under "Tokio drain task survives past child reap". Gated `cfg(all(unix, feature = "ssh-socketpair-stderr"))` so the file no-ops on Windows and on default builds. Adds `tracing` and `tracing-subscriber` as dev-dependencies of `rsync_io`; a custom `Layer` records WARN events with thread-local dispatch propagated to the spawned drain thread.
oferchen
added a commit
that referenced
this pull request
May 18, 2026
…4363) Implements SSE-4 from docs/design/socketpair-stderr-channel.md: when both async-ssh and ssh-socketpair-stderr features are enabled, AsyncSshTransport installs a socketpair-backed stderr channel and drains it via a tokio task into a bounded 8 KiB RingBuffer, emitting tracing::warn! per line. - New module async_stderr_drain.rs gated on both features - RingBuffer<const N: usize> with sliding-window semantics - AsyncStderrDrain::spawn(reader) wires a tokio::spawn drain loop - stderr_capture() snapshot accessor; join() awaits clean EOF - Drop aborts the task safely (it only owns reader + Arc buffer clone) - Wire into AsyncSshTransport::execute_remote_rsync: replace Stdio::inherit with configure_stderr_channel when both features are enabled on Unix; fall back to inherit on FD exhaustion per the design doc - AsyncSshTransport::stderr_capture() returns the bounded snapshot - Unit tests (Unix-only): 1 KiB write/snapshot equality, multi-line capture, clean EOF after sender drop, capture cap enforcement, ring buffer math # Conflicts: # crates/rsync_io/Cargo.toml
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
SSE-6 from docs/design/socketpair-stderr-channel.md. Drives the SSE-3 `make_stderr_socketpair` primitive end-to-end by wiring the child end into a real subprocess as fd 2 and asserting the parent end surfaces the bytes verbatim. Each captured line additionally fires a `tracing::warn!` event, mirroring the production drain shape staged in SSE-4 (#4363) so this test continues to exercise the observable contract once the async path lands. Scenarios: - single_error_line_propagates_through_socketpair: one echo writes `test error message\n`; parent buffer matches byte-for-byte and a single WARN event fires with the captured payload. - multi_error_lines_propagate_and_fire_one_warn_each: three separate echo calls produce three ordered lines; all three are captured in order and one WARN event fires per line. - drain_returns_after_child_exit_closes_child_end: confirms the drain observes EOF cleanly when the subprocess exits and the child end closes, guarding the failure mode the design doc calls out under "Tokio drain task survives past child reap". Gated `cfg(all(unix, feature = "ssh-socketpair-stderr"))` so the file no-ops on Windows and on default builds. Adds `tracing` and `tracing-subscriber` as dev-dependencies of `rsync_io`; a custom `Layer` records WARN events with thread-local dispatch propagated to the spawned drain thread.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…4363) Implements SSE-4 from docs/design/socketpair-stderr-channel.md: when both async-ssh and ssh-socketpair-stderr features are enabled, AsyncSshTransport installs a socketpair-backed stderr channel and drains it via a tokio task into a bounded 8 KiB RingBuffer, emitting tracing::warn! per line. - New module async_stderr_drain.rs gated on both features - RingBuffer<const N: usize> with sliding-window semantics - AsyncStderrDrain::spawn(reader) wires a tokio::spawn drain loop - stderr_capture() snapshot accessor; join() awaits clean EOF - Drop aborts the task safely (it only owns reader + Arc buffer clone) - Wire into AsyncSshTransport::execute_remote_rsync: replace Stdio::inherit with configure_stderr_channel when both features are enabled on Unix; fall back to inherit on FD exhaustion per the design doc - AsyncSshTransport::stderr_capture() returns the bounded snapshot - Unit tests (Unix-only): 1 KiB write/snapshot equality, multi-line capture, clean EOF after sender drop, capture cap enforcement, ring buffer math # Conflicts: # crates/rsync_io/Cargo.toml
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.
Summary
SSE-4 (tracker #2373) from
docs/design/socketpair-stderr-channel.md.Adds an async stderr drain task that replaces
Stdio::inherit()inAsyncSshTransportwhen bothasync-sshand the newssh-socketpair-stderrfeature are enabled.async_stderr_drainmodule gated on both features. Spawns a tokiotask that reads line-by-line from the parent end of the SSH stderr
socketpair (installed by
aux_channel::configure_stderr_channel),appends bytes into a bounded
RingBuffer<8192>, and emits atracing::warn!(target = "ssh::stderr", ...)per line.AsyncSshTransportgains a privatestderr_drain: Option<...>fieldand a public
stderr_capture() -> Vec<u8>snapshot accessor. Onconfigurations without the feature (or non-Unix),
stderr_capturealways returns an empty
Vecso call sites stay unconditional.Stdio::inheriton socketpair FD exhaustion, as thedesign doc prescribes for the async path.
The sync transport's
SocketpairStderrChannelthread drain isunchanged. The new feature is opt-in and default off.
Test plan
cargo fmt --allcleanexercised; tracing dispatcher not asserted on to avoid global-state
flakiness across tests)
joinreturns
Ok)ASYNC_STDERR_BUFFER_CAPRingBufferextend / oversized-extend / empty-extend semanticsLinux musl (stable)
#[cfg(not(...))]branch and thestderr_capture_is_empty_when_feature_disabledcompile-only check)