Repository navigation
Retry a failed full reconnect instead of reporting it as success - #1144
Merged
pblazej merged 3 commits intoOct 6, 2026
Merged
Conversation
bgoepfert
requested review from
hiroshihorie,
pblazej and
xianshijing-lk
as code owners
October 5, 2026 03:44
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
.connected after cleanUp(isFullReconnect:)
Contributor
Author
|
Hello 👋 This is the first time I've opened a PR to contribute to an open-source repo! I am using Livekit and this swift SDK quite heavily in a product I am building, and am keen to get involved when I can, so would be grateful for any general contributing feedback as well. Hopefully I have followed the process right here :) |
Contributor
|
Hey @bgoepfert I did a small update in the tests, thanks for fixing that 💯 There are some CI failures, mostly due to #1131 - I'd merge it first once approved. |
pblazej
approved these changes
Oct 6, 2026
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.
SDK version: 2.17.0 (also present on
main)Platform: macOS 15+ (logic is platform-independent)
Description
In
Room+Engine.swift,startReconnect(reason:nextReconnectMode:), the retry closure passed toTask.retryingstarts with:This
returns normally instead of throwing.Task.retryingtreats a normal return as success, so:fullReconnectSequence(), which callscleanUp(isFullReconnect: true)and then fails (for example, the signal connect or the transport connect times out). The closure rethrows, andTask.retryingwaits and calls the closure again.isReconnectingWithModeis still.full, so the guard returns without doing anything.try await reconnectTask.valuesucceeds, and the code after it setsconnectionState = .connected, clearsreconnectTaskandisReconnectingWithMode, and resets the region attempts.The Room is now
.connected, but its state was reset bycleanUp(isFullReconnect: true). Depending on where the full attempt failed,sidandremoteParticipantsare empty, or the transports are not connected. No further reconnect is attempted, anddidDisconnectnever fires, so the app has no signal that the call is dead.The same thing happens when the very first attempt is a full reconnect (for example, after a server
Leavewith actionreconnect) and that attempt fails while attempts remain.Expected
A failed full reconnect either retries the full reconnect on the remaining attempts, or ends in
.disconnectedwith an error through the existingcatch(cleanUp(withError:)), so thatroom(_:didDisconnectWithError:)fires.Fix
Remove the guard. A later attempt now retries the full reconnect (the closure already picks .full while isReconnectingWithMode == .full), and when every attempt fails the existing catch runs cleanUp(withError:), so room(_:didDisconnectWithError:) fires.
Tests
FailedFullReconnectTests (E2E, local server):
The existing FullReconnectDataTests and RepublishTracksTests still pass.
Steps to reproduce
room.debug_simulate(scenario: .fullReconnect)or a serverLeavewithreconnect), and make the first full attempt fail, for example by blocking network access for about 15 s during the attempt.connectionState == .connected, withroom.sid == nilor emptyremoteParticipants, no media, and no further reconnect or disconnect events.Impact
Users see a "connected" call with no participants or media that never recovers until they leave and rejoin.