I am trying to retrieve the Firebase users in a project. I can retrieve them, but the main program never ends. I debug using VS Code or run the script with npm run and it gets stuck both ways. In VS Code there is nothing left on the stack...it just never stops
**Users function (It returns the users without a problem)
admin.auth().listUsers returns a listUsersResult object with properties nextPageToken and a users array
const BATCH_SIZE = 2;
const listAllUsers = async (nextPageToken = undefined) => {
let listUsersResult = await admin.auth().listUsers(BATCH_SIZE, nextPageToken);
if (listUsersResult.pageToken) {
return listUsersResult.users.concat(await listAllUsers(listUsersResult.pageToken));
} else {
return listUsersResult.users;
}
};
Main Routine (this is the one that gets stuck)
const uploadUsersMain = async () => {
try {
// if I comment out this call, then there is no problem
let firestoreUsers = await listAllUsers();
} catch(error) {
log.error(`Unable to retrieve users ${error}`)
}
finally {
// do stuff
}
}
uploadUsersMain();
What could be the issue that stops the main program from ending? What should I look for? Thanks