User metadata is not correctly updated from a Rule

Problem statement

There are no errors after login execution, but the metadata is empty


  • Data is not persisting if you don’t resolve the Promise


Rules using the function updateUserMetadata() triggers an asynchronous call that needs to be resolved. You’ll be expecting no errors since this function will end with a pending Promise.

Here are a few examples in our documentation:

As you can see in the code snippet below, it’s needed to handle the Promise with “then” and “catch” to persist the data:

function(user, context, callback){
  auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
      callback(null, user, context);