The session connection screen uses the platform client’s callback API, but exposes the result outward through an async method. After a recent refactor, rare hangs and incorrect completion of the wait started appearing when the client emits repeated events.
join(code:) method must return SessionInfo on successful connection.join(code:) must finish with that error.CancellationError.MockSessionClient calls completion twice: first with a cancellation error, then with a successful value.join(code:) inside Task and cancel the task before the second callback arrives.completion at all, and the task is cancelled externally.async-method contract.Example test scenario launch:
let service = SessionJoinService(client: client)
let task = Task {
try await service.join(code: "ROOM-42")
}
task.cancel()
_ = try? await task.value
join(code:) with CancellationError.-swift-version 6async/await, withCheckedThrowingContinuation, withTaskCancellationHandlerSessionJoinService is marked as actor, all access to state happens inside itMockSessionClient with a Result<SessionInfo, Error> -> Void callbackcancelJoin() on the client is idempotent and may be called before or after the callbackUse line comments to explain the problem, its impact, the fix and how to test it.