Repository navigation
Keep retrying when a reconnect's initial request fails - #143
Open
romansorochak wants to merge 2 commits into
Open
romansorochak wants to merge 2 commits into
romansorochak wants to merge 2 commits into
Conversation
After a dropped stream, retryOnError() reopens the source through seek(at:) -> performOpen -> initialRequest, a bytes=0-1 request whose callback only handled .response. If that request failed - the server or network still down a second after the drop - the .stream(.failure) event fell through `default: break`: no stream request was started and no retry was scheduled, so playback stayed in buffering until the user acted. The Retrier itself is idle at that point (its callback's seek already cancelled it); nothing called it again. Route the initial request's failure through handleFailedStreamEvent, the same path the stream's own failures take, so the source keeps retrying (or waits for the network) until a reconnect succeeds. The new RemoteAudioSourceRetryTests drives a loopback server that cuts the stream mid-body and refuses connections for 1.5 s after it; without this change no audio arrives from a later connection and the test times out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8942f0d)
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.
Problem
After a dropped stream,
retryOnError()reopens the source throughseek(at:)→performOpen→initialRequest. That is abytes=0-1request, and its callback handles only.response. If the request fails because the server or the network is still down a second after the drop, the.stream(.failure)event falls throughdefault: break. No stream request starts and no retry is scheduled, so playback stays in buffering until the user does something. TheRetrieris idle at that point, because its callback'sseekalready cancelled it, and nothing calls it again.Fix
Send the initial request's failure through
handleFailedStreamEvent, the same path the stream's own failures take. The source then keeps retrying, or waits for the network, until a reconnect succeeds. The change is 5 lines inRemoteAudioSource.swift.Test
New
RemoteAudioSourceRetryTests. A loopbackNWListenercuts the stream mid-body and then refuses connections for 1.5 s.swift test:Executed 60 tests, with 0 failures.We also saw this in our app: with a server that drops the stream and refuses connections for 3 s, the player stayed in Loading indefinitely before this change, and with it the player reconnects at +3 s and plays.