fix: reject resume requests for stale sessions - #185
Open
brongan wants to merge 1 commit into
Open
Conversation
brongan
force-pushed
the
fix/reject-stale-resume
branch
3 times, most recently
from
August 27, 2026 16:59
e334d3a to
dcad9a8
Compare
The /resume handler currently returns success whenever a session object exists, even after shutdown begins or before streaming is active. It also returns success when the session key sender is missing. Moonlight then waits for a reconnect that cannot produce frames. Reject resume key updates when any of the following is true: - shutdown has started - the existing session is not Active - an Active session has no key sender
brongan
force-pushed
the
fix/reject-stale-resume
branch
from
August 27, 2026 17:02
dcad9a8 to
e765765
Compare
brongan
marked this pull request as ready for review
August 27, 2026 17:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject resume key updates when any of the following is true:
Active.Activesession has no key sender.This is a narrow follow-up to #103. That PR added support for reconnecting to an active stream, but
/resumecurrently treats any existing session object as resumable. The shutdown signal can fire before the watchdog clears that object, leaving a short window where Moonshine acknowledges a resume for a stream that can no longer produce frames.Resume decision
Before this change, any existing session returned status 200. A missing key sender only logged a warning.
flowchart TD A["Receive /resume with new keys"] --> B{"Shutdown started?"} B -- Yes --> X["Return status code 400"] B -- No --> C{"Session is Active?"} C -- No --> X C -- Yes --> D{"Key sender exists?"} D -- No --> X D -- Yes --> E["Replace session keys"] E --> Y["Return status code 200"]The original failure was observed during a Moonlight reconnect: Moonshine logged
ControlStreamStopped, accepted/resumewith status 200 during teardown, and then produced no video before Moonlight's first-frame timeout.