Skip to content

Conversation

robinlinden
Copy link
Collaborator

@robinlinden robinlinden commented Sep 9, 2025

This issue showed up a lot in CI where things are a lot slower. The
createprofile fragment spawns a coroutine that will create a user and
returns before it's done, then the contactlist fragment will try to load
the user, leading to a crash if the user-creation coroutine hasn't done
its thing yet.

With this change, we wait for the user-creation coroutine to complete
before moving to the contactlist fragment.

To reproduce the issue locally, I added a delay(1000) in UserManager::create.

Call stack from CI:

java.lang.IllegalStateException: The query result was empty, but expected a single row to return a NON-NULL object of type <ltd.evilcorp.core.vo.User>.
	at ltd.evilcorp.core.db.UserDao_Impl.load$lambda$3(UserDao_Impl.kt:132)
	at ltd.evilcorp.core.db.UserDao_Impl.$r8$lambda$8QDXdWcf5qEAu-VWErLGcEZTRTg(Unknown Source:0)
	at ltd.evilcorp.core.db.UserDao_Impl$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
	at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$lambda$1$$inlined$internalPerform$1.invokeSuspend(DBUtil.kt:68)
	at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$lambda$1$$inlined$internalPerform$1.invoke(Unknown Source:8)
	at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$lambda$1$$inlined$internalPerform$1.invoke(Unknown Source:4)
	at androidx.room.driver.SupportSQLiteConnectionPool.useConnection(SupportSQLiteConnectionPool.android.kt:42)
	at androidx.room.RoomConnectionManager.useConnection(RoomConnectionManager.android.kt:126)
	at androidx.room.RoomDatabase.useConnection$room_runtime_release(RoomDatabase.android.kt:593)
	at androidx.room.util.DBUtil__DBUtil_androidKt$performSuspending$$inlined$compatCoroutineExecute$DBUtil__DBUtil_androidKt$1.invokeSuspend(DBUtil.android.kt:113)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:920)
	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@64390f3, Dispatchers.Main.immediate]

This has been happening on and off for a few months, but now it happened 5 times in a row in the Gradle 9 update PR and I finally decided to take the time to look into it.

This issue showed up a lot in CI where things are a lot slower. The
createprofile fragment spawns a coroutine that will create a user and
returns before it's done, then the contactlist fragment will try to load
the user, leading to a crash if the user-creation coroutine hasn't done
its thing yet.

With this change, we wait for the user-creation coroutine to complete
before moving to the contactlist fragment.

To reproduce the issue locally, I added a delay(1000) in
UserManager::create.
@robinlinden robinlinden merged commit 85682cb into evilcorpltd:master Sep 9, 2025
14 of 16 checks passed
@robinlinden robinlinden deleted the integrationtest-robustness branch September 9, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant