Skip to content

fix: sync stderr after command completion to fix CI flake#95

Merged
blaspat merged 1 commit into
mainfrom
fix/stderr-sync
Jun 25, 2026
Merged

fix: sync stderr after command completion to fix CI flake#95
blaspat merged 1 commit into
mainfrom
fix/stderr-sync

Conversation

@blaspat

@blaspat blaspat commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Problem

TestRunStderrScopedPerCommand flakes on GitHub Actions CI (no TTY) because bash -i echoes the input frame to stderr while stdout/stderr are separate pipes. The END marker on stdout can signal completion before the stderr pipe has finished delivering the command's output, causing stderr from cmd1 to leak into cmd2's captured stderr.

Fix

  • Added a __HERMES_STDBUF_N__ marker to the execution frame, written to stderr after every user command
  • Run() now spins until the marker appears in stderrBuf before reading the stderr delta
  • The marker is deterministic (no arbitrary sleeps) and comes after the user command in the frame, guaranteeing stderr has flushed

Testing

  • TestRunStderrScopedPerCommand passes 10/10 runs locally
  • Full internal/exec/ suite passes

Adds a __HERMES_STDBUF_N__ marker written to stderr after each
user command in the execution frame. Run() spins until the marker
appears in stderrBuf before reading the stderr delta.

This fixes a race where the END marker on stdout signals completion
before the stderr pipe has finished delivering the command's output.
On CI (no TTY), bash -i echoes the input frame to stderr, which
arrives via a separate pipe — the sync marker ensures captureStderr
has flushed everything before Run reads the buffer.

Fixes TestRunStderrScopedPerCommand flake on GitHub Actions runners.

Signed-off-by: Blasius Patrick <blasius.patrick@gmail.com>
@blaspat blaspat merged commit 31fe152 into main Jun 25, 2026
14 checks passed
@blaspat blaspat deleted the fix/stderr-sync branch June 25, 2026 11:27
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.

1 participant