Looking at the code, it looks like they are not logging into MongoDB/Realm async, they are just checking if it is done, then reloading the page if not.
const user = app.logIn(credentials);
export const client = num_users===0 ?
// wait for 1 second before reloading the page
setTimeout(() => {
window.location.reload();
}, 350) : app.currentUser.mongoClient("mongodb-atlas")
(which coincides with loads of realm users in localstorage if it continues to reload)
This https://www.mongodb.com/docs/realm/web/authenticate/ shows how to login whilst waiting for a user to be created.
Edit: @aditiyadav Hope that doesn't come across wrong, just pointing out where the problem could be :)