Fix race condition in DefaultSocketApi causing disconnection loop when changing credentials
Some checks failed
Repo / Label merge conflict / Triage (push) Has been cancelled
SDK / Documentation / Lint (push) Has been cancelled
SDK / Documentation / Build Vitepress (push) Has been cancelled
SDK / Documentation / Build Dokka (push) Has been cancelled
SDK / Lint / Lint (push) Has been cancelled
SDK / Publish / Publish (push) Has been cancelled
SDK / Test / Test (17) (push) Has been cancelled
SDK / Test / Test (21) (push) Has been cancelled
SDK / Test / Validate binary compatibility (push) Has been cancelled
SDK / Test / Verify OpenAPI sources (push) Has been cancelled
SDK / Unstable branch / Update (push) Has been cancelled
SDK / Documentation / Deploy (push) Has been cancelled

This commit is contained in:
Niels van Velzen 2024-11-19 17:34:39 +01:00 committed by Niels van Velzen
parent d7656db2e7
commit 89d3146891

View File

@ -144,7 +144,7 @@ public class DefaultSocketApi(
.state
.onEach { connectionState ->
// Automatically reconnect when the socket is closed while subscriptions are active
if (_subscriptionCount > 0 && _currentCredentials != null && connectionState is SocketConnectionState.Disconnected) {
if (_subscriptionCount > 0 && _currentCredentials != null && connectionState is SocketConnectionState.Disconnected && !reconnectMutex.isLocked) {
socketReconnectPolicy.notifyDisconnected()
val reconnectDelay = socketReconnectPolicy.getReconnectDelay()