ground-db
ground-db copied to clipboard
Half logged out state when grounding Meteor.users
Hi! This problem is a bit elusive, so I'll try to bring enough information so we could perhaps figure it out:
In my app all users sign in using accounts-facebook. It's vital for my app to keep working and have the user's data when offline, so I'm grounding Meteor.users:
if (Meteor.isClient) {
Meteor.startup(() => {
Ground.Collection(Meteor.users);
});
}
Sometimes, however, when connected to the server, I see that while everything seems to be working ok - the user "seems" to be logged out (i.e.,
If I exit the app and reenters it just becomes connected and signed in again (all becomes OK). I also have some callback registered on "Hooks.onLoggedOut" which never gets called - so the system doesn't know that the user has logged out (because he really didn't log out).
It's really hard to debug since I can't reproduce this problem manually. It just sometimes happens. My guess is that it has to do with some conflict in the grounded Meteor.users. Does that sound reasonable? Any idea how I can go about trying to handle this?
Thanks! Please tell me if you need more info...
Same error here too.
I have the normal username password login, On my Android / IOS apps if the apps were terminated when user is logged in and reopened the logged in status is gone. The user is not there anymore.
But if I terminate the app again and reopen it, I see the user is logged in. this is weird. @raix
If it helps the discussion, I ended implementing my own fix, saving the user's information locally and not grounding Meteor.users anymore. It wasn't easy (since I need to take care of all the synching between Meteor.user() and my own locally saved data manually), but it did fix the issue. I don't see this problem anymore.
Care to share some code please ?
I'd love to, but it's not a simple workaround that I can find a specific piece of code that "did the trick" and paste it here.
Basically, I created a local persistent session variable "localUser" and used a Tracker.autorun to make it synced with Meteor.user(). To address the specific needs of my app, I then also had to add some cases where I want this sync not to happen (e.g., when the user is disconnected from the internet), remember a logout action if it happened when the user was offline, etc. It's really very specific and it's made of code going around many different places in my client codebase.
Sorry :/
Have you tried 2.0.0-rc.3
(mind the new patterns)