Skip to content

Keep container logs writing after an attached client dies - #2046

Open
rogerneal wants to merge 1 commit into
apple:mainfrom
rogerneal:fix/2009-multiwriter-epipe
Open

Keep container logs writing after an attached client dies#2046
rogerneal wants to merge 1 commit into
apple:mainfrom
rogerneal:fix/2009-multiwriter-epipe

Conversation

@rogerneal

@rogerneal rogerneal commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Isolate per-handle write failures in MultiWriter so a dead attached client (EPIPE) does not stop writes to the on-disk container log.
  • Drop handles that fail so later writes do not keep hitting the broken pipe.
  • Move MultiWriter into its own file and add unit tests that reproduce the EPIPE fan-out failure.

Fixes #2009

Test plan

Tested

  • swift test --filter MultiWriterTests
    • writeContinuesToLogAfterClientEPIPE: client pipe closed (EPIPE), log file still receives subsequent writes
    • writeThrowsWhenEveryHandleFails: throws when no handles remain writable
  • Full CLI reproduction with a build of this branch installed under /tmp:
    1. container run --name freeze alpine:latest sh -c 'while true; do echo "tick $(date -u +%H:%M:%S)"; sleep 2; done'
    2. Wait until running with at least 3 ticks (before_count=3, last tick 00:07:31)
    3. kill -9 the attached container run PID
    4. Wait 14s; container stayed running
    5. container logs freeze showed 7 additional ticks through tick 00:07:45 (after_count=10)
  • Tests ignore SIGPIPE the same way RuntimeLinuxHelper does, so broken-pipe writes surface as EPIPE

Isolate per-handle failures in MultiWriter so an EPIPE from a dead
client stdio handle cannot abort writes to the on-disk container log.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

[Bug]: Container log file stops receiving output permanently when an attached client dies (MultiWriter aborts fan-out on first EPIPE)

1 participant