Repository navigation
Description
What happened
When a Jellyfin client stops playback while its transcode is being rebuilt, the stop closes nothing and the rebuild then registers a running transcode for a play that has ended. FFmpeg keeps encoding for a session nobody is watching.
A rebuild holds the session lifecycle lock from before it starts FFmpeg until it registers the new transcode. The Jellyfin stop path closes the transcode without taking that lock. If the stop runs during the rebuild, it finds no transcode registered and returns. The rebuild finishes afterwards and registers its transcode without checking whether the play ended.
Steps to reproduce
Not reproduced on a deployment. The trigger, from the source and a focused run:
- Play a transcoded stream from a Jellyfin client on a single-server deployment (integrated transcoding).
- Have the session lose its FFmpeg process (for example a server restart), so the next request rebuilds it.
- While the rebuild is starting FFmpeg, stop playback in the client.
- The rebuild completes and registers its transcode after the stop has returned.
A focused test on main drove ReconstructTranscodeWithError with a start function held open, called CloseTranscodeSession for the same session while it was held, then released it. After the stop, GetTranscodeSession returned nothing. After the rebuild returned, it returned a running transcode.
Expected behavior
A stop that arrives during a rebuild should win: the rebuilt transcode is closed, or is never registered, once the play has ended.
Silo version / commit
main at 2e05489
Deployment
Other
Area
Playback and transcoding
Clients affected
- Web UI
- Android
- iOS/tvOS/macOS
- Jellyfin-compat client (Infuse, Findroid, ...)
- Other/not client-specific
Client app and device
No response
Media and playback details
Any transcoded stream whose rebuild starts successfully.
Diagnostics report reference
No response
Relevant logs
No logs available.
Technical notes
Line numbers are for 2e05489.
internal/jellycompat/streams.go:2034:cleanupPlaySessioncallsh.tm.CloseTranscodeSession(...)without the session lifecycle lock. It takes that lock only later, around the recipe delete (:2058).internal/playback/transcode_manager.go:1004:doReconstructTranscodetakes the lifecycle lock, starts FFmpeg, and registers the result at:1074. Before registering it checks for shutdown and for an existing transcode, not for a stop.internal/playback/transcode_manager.go:1162:CloseTranscodeSessionremoves and closes whatever is registered, and records nothing when it finds no transcode.- The native stop at
internal/api/handlers/playback_v3.go:4628takes the lifecycle lock before it closes the transcode, so it waits for the rebuild. The transcode node records a stop fence that its rebuild checks. The integrated manager has neither for the Jellyfin path. - I found nothing in the integrated manager that expires a registered transcode whose playback session has finished. How long the process runs was not measured.
- Not checked: whether the other Jellyfin close calls (
internal/jellycompat/handlers_playback.go:1371,:1405,:1434) have the same ordering.
#4110 makes a rebuild's later attempts start after the request that triggered it has ended. Before it, an HEVC, capped-VAAPI, or burned-in-subtitle rebuild whose request ended failed instead of registering, so #4110 extends this race to those rebuilds. H.264 rebuilds have it on main today.
AI harness
Claude Code (T3 Code)
AI tool(s)
Claude Code review subagents, T3 Code delegated review, git, Go (go test)
AI model(s)
claude-fable-5-2, gpt-6.1-sol
AI involvement
Fully AI-generated (not yet human verified)
Independent or adversarial review
Found by gpt-6.1-sol while reviewing the plan for #4110, then confirmed by claude-fable-5-2 with the focused test above and traced again by a separate review agent. Not yet checked by a person.
Confirmations
- I searched open and recently closed issues and pull requests, and this is not already reported
- I reproduced this myself on a real deployment
- Any logs provided are raw apart from marked redactions and are not AI-summarized; if none were available, I said so above
Source: found in review of #4110
Activity
Quick104 commentedon Nov 13, 2026
🤖 AI agent claim. Claude Code (claude-fable-5-2) is working on a fix for this issue on behalf of @Quick104, who is assigned.
A pull request will link here when the fix is ready. If the work stops without a fix, the assignment and this comment are removed.
Planning to work on this, or have context to add? Reply here and mention @Quick104.
fix(jellycompat): close a transcode that was starting when a Jellyfin…