File tree Expand file tree Collapse file tree 3 files changed +22
-7
lines changed
connectors/supabase/src/commonMain/kotlin/com/powersync/connector/supabase
shared/src/commonMain/kotlin/com/powersync/demos Expand file tree Collapse file tree 3 files changed +22
-7
lines changed Original file line number Diff line number Diff line change 11package com.powersync.connector.supabase
22
3+ import co.touchlab.kermit.Logger
34import com.powersync.PowerSyncDatabase
45import com.powersync.connectors.PowerSyncBackendConnector
56import com.powersync.connectors.PowerSyncCredentials
@@ -12,6 +13,7 @@ import io.github.jan.supabase.auth.providers.builtin.Email
1213import io.github.jan.supabase.auth.status.SessionStatus
1314import io.github.jan.supabase.auth.user.UserSession
1415import io.github.jan.supabase.createSupabaseClient
16+ import io.github.jan.supabase.exceptions.BadRequestRestException
1517import io.github.jan.supabase.postgrest.Postgrest
1618import io.github.jan.supabase.postgrest.from
1719import kotlinx.coroutines.flow.StateFlow
@@ -136,8 +138,19 @@ public class SupabaseConnector(
136138
137139 transaction.complete(null )
138140 } catch (e: Exception ) {
139- println (" Data upload error - retrying last entry: ${lastEntry!! } , $e " )
140- throw e
141+ when (e) {
142+ is BadRequestRestException -> {
143+ if (e.message?.contains(" violates not-null constraint" ) == true ) {
144+ Logger .e(" Not-null constraint violation: ${e.message} " )
145+ transaction.complete(null )
146+ return
147+ }
148+ }
149+ else -> {
150+ Logger .e(" Data upload error - retrying last entry: $lastEntry , $e " )
151+ throw e
152+ }
153+ }
141154 }
142155 }
143156}
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ ktor = "3.0.1"
1414uuid = " 0.8.2"
1515buildKonfig = " 0.15.1"
1616
17- supabase = " 3.0.1"
1817junit = " 4.13.2"
1918
2019compose = " 1.6.11"
@@ -51,9 +50,6 @@ ktor-client-contentnegotiation = { module = "io.ktor:ktor-client-content-negotia
5150ktor-serialization-json = { module = " io.ktor:ktor-serialization-kotlinx-json" , version.ref = " ktor" }
5251kotlinx-coroutines-core = { module = " org.jetbrains.kotlinx:kotlinx-coroutines-core" , version.ref = " coroutines" }
5352
54- supabase-client = { module = " io.github.jan-tennert.supabase:postgrest-kt" , version.ref = " supabase" }
55- supabase-auth = { module = " io.github.jan-tennert.supabase:auth-kt" , version.ref = " supabase" }
56-
5753androidx-core = { group = " androidx.core" , name = " core-ktx" , version.ref = " androidx-core" }
5854androidx-appcompat = { group = " androidx.appcompat" , name = " appcompat" , version.ref = " androidx-appcompat" }
5955androidx-activity-compose = { module = " androidx.activity:activity-compose" , version.ref = " androidx-activity-compose" }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
55import co.touchlab.kermit.Logger
66import com.powersync.PowerSyncDatabase
77import com.powersync.connector.supabase.SupabaseConnector
8+ import io.github.jan.supabase.auth.status.RefreshFailureCause
89import io.github.jan.supabase.auth.status.SessionStatus
910import kotlinx.coroutines.flow.MutableStateFlow
1011import kotlinx.coroutines.flow.StateFlow
@@ -38,7 +39,12 @@ internal class AuthViewModel(
3839 }
3940
4041 SessionStatus .Initializing -> Logger .e(" Loading from storage" )
41- SessionStatus .RefreshFailure (cause) -> Logger .e(" Network error" )
42+ is SessionStatus .RefreshFailure -> {
43+ when (it.cause) {
44+ is RefreshFailureCause .NetworkError -> Logger .e(" Network error occurred" )
45+ is RefreshFailureCause .InternalServerError -> Logger .e(" Internal server error occurred" )
46+ }
47+ }
4248 is SessionStatus .NotAuthenticated -> {
4349 db.disconnectAndClear()
4450 _authState .value = AuthState .SignedOut
You can’t perform that action at this time.
0 commit comments