Repository navigation
fix(media-server): preserve audio output and report stream failures - #2882
yashranaway wants to merge 2 commits into
Conversation
|
@greptileai review |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
| const cleanup = (error = new Error("Audio extraction cancelled")) => { | ||
| if (cleaned) return; | ||
| cleaned = true; | ||
| streamController?.error(error); |
There was a problem hiding this comment.
cleanup() now errors the stream even after a successful extraction. With highWaterMark: 4, pull() can reach stdout EOF while chunks remain queued for a slow reader. controller.close() waits for those chunks to drain, but the following cleanup() calls error(), discarding them and rejecting the reader with Audio extraction cancelled.
Separate successful cleanup from cancellation, and add a test that pauses between reads through EOF.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/media-server/src/lib/media-audio.ts
Line: 407
Comment:
**Successful audio streams fail**
`cleanup()` now errors the stream even after a successful extraction. With `highWaterMark: 4`, `pull()` can reach stdout EOF while chunks remain queued for a slow reader. `controller.close()` waits for those chunks to drain, but the following `cleanup()` calls `error()`, discarding them and rejecting the reader with `Audio extraction cancelled`.
Separate successful cleanup from cancellation, and add a test that pauses between reads through EOF.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Good catch, that was a real regression. A clean EOF now just closes the stream so the queued audio still reaches the reader, and only cancel, timeout or an ffmpeg failure errors it. Added a test that reads slowly through EOF and checks the full output, it failed before the fix (024bb01).
the media server's streaming audio extract cleaned up as soon as ffmpeg exited, which cancelled stdout even if the client hadn't read the last chunks yet. a slow consumer could get truncated or empty audio, and because the exit code was ignored, an ffmpeg failure or a timeout just looked like a short successful stream.
now a clean exit leaves stdout to drain fully before closing, and a non zero exit or a timeout errors the stream instead. the integration tests run real ffmpeg with a slow reader and a failing input.
Fix successful cleanup before merging; slow readers can still lose audio and receive a cancellation error.
Findings
Fix with agent prompt
Summary
The PR keeps stdout available after FFmpeg exits successfully and reports nonzero exits and timeouts as stream errors.
Reviews (1) · Last reviewed commit: "fix(media-server): preserve audio output..." · Reviewed by Greptile