Fix hard crash loop for unreachable servers

It should be noted that this is a band-aid fix for deeper underlying issues.

The code as-was would attempt a login on every init, including when apps like Mihon would recover from the first crash by going to their global crash handler activity.

This usually happened whenever a user would be unable to connect to their Kavita instance (server not up, different/no networks, etc) and left the user unable to fix the issue by removing the broken API URL or uninstalling the extension through the app's menus.

It doesn't matter if the Kavita instance that is unreachable is disabled in the extension settings, the crash will still occur because the login is performed in the init block, which is called regardless of an extension's specific enable/disable state (to be able to display settings, etc).
This commit is contained in:
MajorTanya
2025-12-21 10:04:02 +01:00
parent 6780871c0f
commit 13657ba2dc

View File

@@ -2587,10 +2587,8 @@ class Kavita(private val suffix: String = "") : ConfigurableSource, UnmeteredSou
try {
Log.d(LOG_TAG, "Starting Kavita extension initialization")
// First attempt login with timeout
val loginJob = async { doLogin() }
try {
loginJob.await()
doLogin()
} catch (e: Exception) {
Log.e(LOG_TAG, "Login failed during initialization", e)
initializationError = e