Skip to content

Commit be7475d

Browse files
committed
fix(kotlin-enhanced): do not overwrite status with Error on disconnect
RealtimeClient catch block was setting ConnectionStatus.Error on CancellationException when disconnect() cancels the connection job. Rethrow CancellationException so status stays Disconnected after disconnect. Made-with: Cursor
1 parent 1e08d02 commit be7475d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • sdk/kotlin-enhanced/src/jvmMain/kotlin/com/flagent/enhanced/realtime

sdk/kotlin-enhanced/src/jvmMain/kotlin/com/flagent/enhanced/realtime/RealtimeClient.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.ktor.client.HttpClient
44
import io.ktor.client.plugins.sse.sse
55
import io.ktor.client.request.get
66
import io.ktor.sse.ServerSentEvent
7+
import kotlinx.coroutines.CancellationException
78
import kotlinx.coroutines.CoroutineScope
89
import kotlinx.coroutines.Dispatchers
910
import kotlinx.coroutines.Job
@@ -73,6 +74,7 @@ class RealtimeClient(
7374
_connectionStatus.value = ConnectionStatus.Disconnected
7475
logger.info { "SSE connection closed" }
7576
} catch (e: Exception) {
77+
if (e is CancellationException) throw e
7678
logger.error(e) { "SSE connection error: ${e.message}" }
7779
_connectionStatus.value = ConnectionStatus.Error(e.message ?: "Unknown error")
7880
if (!config.autoReconnect) break

0 commit comments

Comments
 (0)