Fix websocket reconnect race due to async IMO termination.

This commit is contained in:
Cody Henthorne
2025-11-13 16:02:40 -05:00
parent 4efcf14b7a
commit a3e3291d9c
2 changed files with 5 additions and 9 deletions

View File

@@ -252,7 +252,7 @@ class NetworkDependenciesModule(
fun closeConnections() {
Log.i(TAG, "Closing connections.")
incomingMessageObserver.terminateAsync()
incomingMessageObserver.terminate()
if (_signalServiceMessageSender.isInitialized()) {
signalServiceMessageSender.cancelInFlightRequests()
}

View File

@@ -265,17 +265,13 @@ class IncomingMessageObserver(
}
}
fun terminateAsync() {
Log.w(TAG, "Termination Enqueued! ${this.hashCode()}", Throwable())
fun terminate() {
Log.w(TAG, "Termination! ${this.hashCode()}", Throwable())
INSTANCE_COUNT.decrementAndGet()
networkConnectionListener.unregister()
webSocketStateDisposable.dispose()
SignalExecutors.BOUNDED.execute {
Log.w(TAG, "Beginning termination. ${this.hashCode()}")
terminated = true
Log.w(TAG, "Disconnecting auth socket as part of termination")
authWebSocket.disconnect()
}
terminated = true
authWebSocket.disconnect()
}
@VisibleForTesting