Skip to content

fix(cli): degrade a dead log transport to dropped output (issue #339) - #343

Merged
turinglambdaai merged 5 commits into
mainfrom
fix/tolerant-cli-logging
Oct 29, 2026
Merged

turinglambdaai merged 5 commits into
mainfrom
fix/tolerant-cli-logging

Conversation

@turinglambdaai

Copy link
Copy Markdown
Owner

Closes #339.

Failure mode

On GitHub Actions windows-latest runners, raco rivet build for a WinUI 3 app intermittently fails with

    0 Error(s)
error writing to stream port
  system error: Invalid access to memory location.; win_err=998
##[error]Process completed with exit code 1.

even though the child MSBuild exited 0 and the executable was produced (the link steps and 0 Error(s) summary are right there in the log). Three occurrences in one day on the shuttle private repo; every immediate rerun was green.

Root cause

The CLI runs tools with inherited stdout/stderr. On Actions, that ambient stdout is the hosted log pipe. When the runner-side log processing drops the pipe, the next printf/eprintf from rivet itself raises error writing to stream port — and because the whole command runs on those ports, a log-transport failure is conflated with a build failure.

Fix

rivet-cli/main.rkt wraps the command dispatch in call-with-tolerant-logging (rivet-cli/tolerant-log.rkt): both ambient ports become delegating ports whose failed write (or failed close) is treated as a completed write — the bytes are dropped, the command keeps running. The child's exit code remains the only success signal; healthy transports pass output through byte-for-byte, byte order preserved.

Deliberately minimal: no child-process redirection, no buffering, no behavior change other than not dying when the sink dies.

Tests

rivet/tests/tolerant-log.rkt:

  • passthrough fidelity to a healthy port,
  • thousands of interleaved stdout/stderr writes into transports that raise on every write (the issue's signature),
  • a raising close handler (covers exit-path cleanup).

Local: suite green (raco test rivet/tests/); CLI smoke (raco rivet --help, doctor) unchanged.

CHANGELOG

### Fixed entry under Unreleased.

ren.ji and others added 4 commits October 28, 2026 23:07
On GitHub Actions windows-latest runners, raco rivet build intermittently
fails with `error writing to stream port` (win_err=998) after the child
MSBuild already exited 0 and produced the exe: the hosted log pipe dies
under the CLI and the next printf from rivet raises, conflating a log
transport failure with a build failure. Three occurrences observed in
one day, each rerun green.

Wrap the command dispatch in tolerant ports: a failed write (or close)
on the ambient stdout/stderr is treated as a completed one and the bytes
are dropped. The child's exit code stays the only success signal, and
healthy transports pass output through byte-for-byte.

Regression tests cover passthrough, thousands of writes into dead
transports, and a raising close handler.

Copy link
Copy Markdown
Owner Author

Follow-up review fix added at cf714a142a250a5b02d2888c518c44a1716bf4b6: the tolerant CLI output wrapper borrows current-output-port/current-error-port; its close callback must not close the original ambient port. Previously close-output-port proxy closed the caller-owned terminal/log stream, which could poison later output. The wrapper now drops its own close without affecting the underlying sink. Added regression coverage for both ordinary borrowed string sink and a base port with a failing/observable close handler. CI must be assessed again on the new head; prior greens on 0d3d126 do not validate these new commits.

@turinglambdaai
turinglambdaai merged commit 9933992 into main Oct 29, 2026
23 checks passed
@github-actions
github-actions Bot deleted the fix/tolerant-cli-logging branch October 29, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: log-stream write failure (win_err=998) fails an otherwise successful MSBuild build on GH Actions windows-latest

1 participant