Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When user logs out Meteor.user() becomes undefined while Meteor.userId() is still a string #11379

Closed
ksinas opened this issue Apr 8, 2021 · 2 comments

Comments

@ksinas
Copy link

ksinas commented Apr 8, 2021

During logout sometimes user becomes undefined while userId holds the previous value
Occurs on versions 2.1.1 and 1.11.1 on Chrome browser

Reproduction

Register autorun on the client

Tracker.autorun(() => {
  console.log(Meteor.user(), Meteor.userId());
});

Open the console and do the following several times

// 1
Meteor.loginWithPassword({ username: 'user'}, 'password')
// 2
Meteor.logout()

Expected behaviour

// console output
someUserId, { _id: 'someUserId... }
null, null

Actual behaviour

// console output
someUserId, { _id: 'someUserId... }
someUserId, undefined
null, null

My guess would be that Meteor.defer() is not working correctly on chrome browser. I had issues related to that here
meteor/react-packages#324 (comment)

@afrokick
Copy link
Contributor

AFAIK the logging out process is async operation. You can call Meteor.loggingOut() function to get a current state.

So, if you'll log it, it should be like:

// console output
someUserId, { _id: 'someUserId... }
someUserId, undefined, true <--- Meteor.loggingOut()
null, null, false

@ksinas
Copy link
Author

ksinas commented Apr 21, 2021

My point is that behaviour was inconsistent between browsers. However, I can't reproduce the issue on chrome 90. I guess the issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants