getUsers doesn't include recently updated metadata

I am using the node-auth0 package, and I have a call to management.updateUserMetadata() followed by management.getUsers(). The response from getUsers() doesn’t seem to include the changes that I made to the metadata in updateUserMetadata(). If I call getUser for the specific updated user then I can see the updates, but getUsers() doesn’t seem to include the results, unless if I wait for a few seconds before calling it. Are these methods not synchronized? Or is there something I am doing wrong? I’ve included some sample code below that illustrates the issue I am seeing with a simple nested callback.

var auth0 = require('auth0');
var _ = require('lodash');

let ManagementClient = auth0.ManagementClient;
let management = new ManagementClient({
    token: 'token',
    domain: 'domain'

var userId = 'auth0|userid';
var metadata = {
    testValue: 'newValue'

management.updateUserMetadata({ id: userId }, metadata).then(function(updateResponse) {
    // This response looks correct:

    let params = {
        per_page: 100,
        page: 0,
        q: 'identities.connection:connection-name'
    management.getUsers(params).then(function(auth0Users) {
        var findUser = _.find(auth0Users, { user_id: userId });
        // this still has the data that looks like prior to the update above. 

This is caused because getUsers implements ElasticSearch and the data needs to be indexed in ElasticSearch before you can retrieve it. Unfortunately, this can take upto a few seconds, if you know the user_id ahead of time. Its better to use getUser instead as it’ll return the true state of the user.

Got it, thank you for the reply. That makes sense, and explains the behavior I am seeing. Unfortunately it doesn’t make things easier, as I am building an internal screen that show a list of users, and a screen for editing a user. When you “save” your changes to a user I navigate back to the screen that lists users, and I query using getUsers(), but it doesn’t show my latest saved changes. I can work-around this, but it’s not as clean as I would have hoped.

Thank you again for the explanation!