Auth0 Home Blog Docs

User list not updating quickly on creation race condition

user-creation
users-list

#1

After creating a user through the management API, how long does it take. This code fails to see the new user but the same command works if I wait for some time

auth0.users.create(
      {
         "connection": settings.AUTH0_DATABASE,
         "email": email,
          "username": "X",
          "password": password,
           "email_verified": False,
           "verify_email": False,
           "user_metadata": {
                   "first_name": validated_data'first_name'],
                    "last_name": validated_data'last_name'],
              }
})
print auth0.users.list(q=(' identities.connection:"%s"' % (settings.AUTH0_DATABASE)), search_engine='v2')

The list returned does not contain the new user


#2

@jmangelo, any thoughts ?


#3

The user search feature you are using is not synchronous to change operations performed on a user as demonstrated by the flow you described in your question. In addition, there’s also not a concrete amount of time you need to wait as in ideal conditions is almost as if it was synchronous, but in conditions where there may be additional load in the system or the user profile data of the associated user is also complex, the window of time might increase.

I’m assuming that the code provided was just to illustrate the issue and it’s just sample code, otherwise for this specific case the recommendation would be to not depend on searching for the new user and instead just reuse the information available from the create call. If you use cases where this asynchronous nature is completely blocking from implementing your goal it would also be interesting if you could share them.


#4