fix: make command and pipeline lifecycles failure-safe#5
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Why
Process execution gets difficult when only part of an operation succeeds: a downstream pipeline stage fails to start, stdout and stderr arrive together, a writer accepts only part of a chunk, or a timeout replaces an already-canceled context.
This pass makes those paths settle cleanly without losing output, leaking processes, racing callbacks, or changing execx's public v1 error model.
What
ErrExec.StdinBytesinput so later caller mutation cannot change execution.Before / after
\nErrExecreturnedStdinBytesThe existing API now also delivers a child's last unterminated line:
Compatibility
This is not a breaking API release: exported signatures and execx's v1 child-exit model remain unchanged.
The observable corrections surface failures that were previously lost, retain final unterminated output, preserve parent cancellation, and copy caller-owned input. Callers that unknowingly relied on swallowed reader, writer, or PTY errors may now receive
ErrExec; that is the documented error boundary working as intended rather than a new error model.The non-Unix build fallbacks are additive and keep the same no-op process-control contract used on unsupported platforms.
Notes
There are no exported signature changes. Non-zero child exit remains data in
Result.ExitCode, not a Go error.Intentional behavior corrections:
StdinBytesno longer observes later slice mutation;Callbacks are serialized, so slow callback work applies backpressure.
Cmdremains mutable and should not be configured or executed concurrently.Review
pipeline.gocovers partial startup, wait ordering, cleanup, and strict/best-effort result selection.execx.gocontains writer construction, context ancestry, and input ownership.execx_test.goand PTY tests capture the corrected failure paths.