Open
Description
General Info
- I checked for similar bug report
- I am using the latest version
- I checked the troubleshooting page for similar problems
Version(s)
3.0.14
Kotlin Target(s) and their respective versions
JVM 21, Android 15
What happened? (include your code)
Resumed app and immediately started subscriptions. Connected to realtime socket before sessionStatus
was updated. RealtimeChannelImpl
attempts to join with expired token and gets: Received message without event: RealtimeMessage(topic=realtime:db-changes, event=phx_reply, payload={"status":"error","response":{"reason":"Token has expired 59 seconds ago"}}, ref=null)
val channel = supabase.realtime.channel("db-changes")
try {
tables.forEach { table ->
channel.postgresChangeFlow<PostgresAction>(schema = "public") {
this.table = table
filter(FilterOperation("account_id", FilterOperator.EQ, accountId))
}
.onEach {
syncTable(table)
}
.launchIn(this)
}
channel.subscribe(true)
launch {
supabase.realtime.status.collectLatest { status ->
syncAllTables()
}
}
awaitCancellation()
} catch (e: Exception) {
logger.i(e) { "subscription cancelled" }
throw e
} finally {
withContext(NonCancellable) {
channel.unsubscribe()
supabase.realtime.removeChannel(channel)
}
}
Steps To Reproduce (optional)
- Get access token
- put app in background
- Wait until access token expires
- Resume app and start subscriptions before access token can be updated