Skip to content

Replace shared subprocessStderr with per-subprocess pipes#17

Merged
zyla merged 2 commits intomainfrom
fix/per-subprocess-stderr-pipes
Mar 17, 2026
Merged

Replace shared subprocessStderr with per-subprocess pipes#17
zyla merged 2 commits intomainfrom
fix/per-subprocess-stderr-pipes

Conversation

@zyla
Copy link
Collaborator

@zyla zyla commented Mar 14, 2026

Summary

  • Introduces withStderrPipe helper: each subprocess creates its own pipe, reads/prefixes output, and cleans up independently — no shared state or lifetime issues
  • Fixes the getCurrentCommit TODO (previously fell back to raw stderr as a workaround for the shared pipe problem)
  • Moves timeoutStream to before success messages are logged, eliminating output ordering race condition which caused flakiness in tests (e.g. https://github.com/restaumatic/taskrunner/actions/runs/23081371040/job/67051182317)

🤖 Generated with Claude Code

zyla and others added 2 commits March 14, 2026 05:54
This test runs a snapshot with --cmd that writes to both stdout and
stderr. It currently documents a bug: subprocessStderr is closed before
runPostUnpackCmd runs, causing hDuplicate to fail with "Bad file
descriptor".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The shared subprocessStderr pipe caused "Bad file descriptor" crashes
when runPostUnpackCmd or RemoteCache.saveCache tried to write after the
pipe's write-end was closed. Instead of shuffling close timing, each
subprocess now creates its own pipe via withStderrPipe, reads/prefixes
its output, and cleans up independently.

- Remove subprocessStderr field from AppState
- Add withStderrPipe helper to Utils.hs (create-pipe, spawn-handler,
  run-action, close-and-wait pattern)
- Move outputStreamHandler, timeoutStream, ignoreEOF to Utils.hs
- Update all callsites: isDirtyAtPaths, getCurrentBranch,
  getMainBranchCommit, getCurrentCommit, runPostUnpackCmd,
  hashFileInputs
- Update packTar/unpackTar to accept stderr handle parameter
- Fix getCurrentCommit TODO (was using raw stderr as workaround)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks if post-unpack-cmd can use stdout and stderr

@zyla zyla requested review from jborkowski and kozak March 14, 2026 06:09
@zyla zyla mentioned this pull request Mar 17, 2026
2 tasks
@zyla zyla merged commit 7bd4a76 into main Mar 17, 2026
2 checks passed
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