Skip to content

fix(cap-muxer): finish the open fragment when the recorder dies - #2644

Merged
richiemcilroy merged 4 commits into
mainfrom
fix/cap-muxer-survives-recorder-crash
Oct 18, 2026
Merged

richiemcilroy merged 4 commits into
mainfrom
fix/cap-muxer-survives-recorder-crash

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

When the recorder dies while the experimental out-of-process muxer is recording, cap-muxer is supposed to see EOF on stdin and finish the fragment it has open. It panics instead, because the recorder's end of its stderr pipe is gone, and the open fragment is left as a 0-byte .tmp.

sequenceDiagram
    participant R as Recorder
    participant M as cap-muxer
    R--xR: SIGKILL (stdin and stderr pipe readers close)
    M->>M: stdin EOF: "stdin closed without Finish"
    M->>M: tracing writes the line to stderr: EPIPE
    M->>M: tracing-subscriber reports the write error with eprintln!: panic (exit 101)
    Note over M: write_trailer never runs: segment_NNN.m4s.tmp stays 0 bytes
Loading
  • tracing_subscriber::fmt() reports a failed write with eprintln!, which panics on a closed stderr; the error paths in main used eprintln! too (crates/cap-muxer/src/main.rs:22).
  • The subscriber now runs with log_internal_errors(false), and the exit messages go through writeln!(io::stderr(), ..) with the error ignored, so a lost stderr never stops the muxer from finishing.

Effect

crates/cap-muxer/tests/orphaned.rs feeds 75 libx264 frames (keyframe every 30) to the real binary, closes its stderr reader, then stdin:

exit code fragments on disk
before 101 (panic) 2 finished, open one lost
after 0 3 finished

Engine-verify crash suite, Blacksmith macOS, recorder killed mid-fragment with the out-of-process muxer (on top of the per-packet flush, #2643):

kill point before after
frame 175 open fragment left as a 0-byte .tmp: frames 120-175 lost finished by the orphaned muxer: complete on disk up to frame 175, 0 lost
frame 120 (rollover) 0-byte .tmp: frames 60-120 lost complete up to frame 120, 0 lost
frame 125, 11 s into a static screen 0-byte .tmp complete up to the last handed frame, 0 lost

Recovery keeps the finished fragment only with the pending-fragment recovery fix (#2640): the recorder's manifest still lists it as pending.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; both previous concerns are addressed.

Summary

Makes stderr writes non-panicking so cap-muxer can finish its open fragment after the recorder dies.

  • The muxer finishes its open fragment when the recorder exits.

Reviews (2) · Last reviewed commit: "test(cap-muxer): always log the EOF warn..." · Reviewed by Greptile

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

View 2 other findings in Capy.

Open in Capy

Comment thread crates/cap-muxer/tests/orphaned.rs
Comment thread crates/cap-muxer/tests/orphaned.rs Outdated
@richiemcilroy

Copy link
Copy Markdown
Member Author

hey @greptileai, please re-review the PR

@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cap-status Ready Ready Preview Oct 18, 2026 3:00pm UTC

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

Open in Capy

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

Open in Capy

@richiemcilroy
richiemcilroy merged commit ada2be5 into main Oct 18, 2026
53 checks passed

This branch was successfully deployed

2 active deployments
Preview – cap-web — d394f619 Deployed Oct 18, 2026 by vercel[bot]
Preview – cap-status — d394f619 Deployed Oct 18, 2026 by vercel[bot]
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