Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: Add retry for admin client sign in for test (#5767)

Khor Shu Henge426970eed79
diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
index ca55923d9f..b3b5dac8c8 100644
--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
+++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
@@ -620,9 +620,18 @@ async fn get_admin_client(client: &Arc<AFCloudClient>) -> FlowyResult<Client> {
ClientConfiguration::default(),
&client.client_version.to_string(),
);
- admin_client
+ // When multiple admin_client instances attempt to sign in concurrently, multiple admin user
+ // creation transaction will be created, but only the first attempt will succeed due to the
+ // unique email constraint. Once the user has been created, admin_client instances can sign in
+ // concurrently without issue.
+ let resp = admin_client
.sign_in_password(&admin_email, &admin_password)
- .await?;
+ .await;
+ if resp.is_err() {
+ admin_client
+ .sign_in_password(&admin_email, &admin_password)
+ .await?;
+ };
Ok(admin_client)
}