Fix possible race in user creation #1319
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.