Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: supabase-community/supabase-kt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.1.0
Choose a base ref
...
head repository: supabase-community/supabase-kt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.1.1
Choose a head ref
  • 5 commits
  • 3 files changed
  • 1 contributor

Commits on Feb 2, 2025

  1. Make HttpRequestException inherit from IOException

    jan-tennert committed Feb 2, 2025
    Copy the full SHA
    74a0a8b View commit details

Commits on Feb 4, 2025

  1. Catch any exceptions when sending a message in realtime

    jan-tennert committed Feb 4, 2025
    Copy the full SHA
    fad060c View commit details
  2. Merge pull request #847 from supabase-community/io-exception

    Make `HttpRequestException` inherit from `IOException`
    jan-tennert authored Feb 4, 2025
    Copy the full SHA
    59beb73 View commit details
  3. Merge pull request #848 from supabase-community/catch-send

    Catch any exceptions when sending a message in realtime
    jan-tennert authored Feb 4, 2025
    Copy the full SHA
    f8c9326 View commit details
  4. Update gradle.properties

    jan-tennert authored Feb 4, 2025
    Copy the full SHA
    4f06243 View commit details
Original file line number Diff line number Diff line change
@@ -87,10 +87,7 @@ import kotlin.io.encoding.ExperimentalEncodingApi
Error while trying to connect to realtime websocket. Trying again in ${config.reconnectDelay}
URL: $websocketUrl
""".trimIndent() }
scope.launch {
disconnect()
connect(true)
}
reconnect()
}
}

@@ -132,10 +129,7 @@ import kotlin.io.encoding.ExperimentalEncodingApi
} catch(e: Exception) {
if(!isActive) return@launch
Realtime.logger.e(e) { "Error while listening for messages. Trying again in ${config.reconnectDelay}" }
scope.launch {
disconnect()
connect(true)
}
reconnect()
}
}
}
@@ -206,10 +200,7 @@ import kotlin.io.encoding.ExperimentalEncodingApi
heartbeatRef = 0
ref = 0
Realtime.logger.e { "Heartbeat timeout. Trying to reconnect in ${config.reconnectDelay}" }
scope.launch {
disconnect()
connect(true)
}
reconnect()
return
}
Realtime.logger.d { "Sending heartbeat" }
@@ -280,11 +271,23 @@ import kotlin.io.encoding.ExperimentalEncodingApi
}

override suspend fun send(message: RealtimeMessage) {
ws?.send(message)
try {
ws?.send(message)
} catch(e: Exception) {
Realtime.logger.e(e) { "Error while sending message $message. Reconnecting in ${config.reconnectDelay}" }
reconnect()
}
}

fun nextIncrementId(): Int {
return incrementId++
}

private fun reconnect() {
scope.launch {
disconnect()
connect(true)
}
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.github.jan.supabase.exceptions

import io.ktor.client.request.HttpRequestBuilder
import kotlinx.io.IOException

/**
* An exception that is thrown when a request fails due to network issues
*/
class HttpRequestException(message: String, request: HttpRequestBuilder): Exception("HTTP request to ${request.url.buildString()} (${request.method.value}) failed with message: $message")
class HttpRequestException(message: String, request: HttpRequestBuilder): IOException("HTTP request to ${request.url.buildString()} (${request.method.value}) failed with message: $message")
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -10,5 +10,5 @@ org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

supabase-version = 3.1.0
supabase-version = 3.1.1
base-group = io.github.jan-tennert.supabase