Accounts.logoutOtherClients() seems to be broken

There have been a couple of posts on this over the last few months, but I think we need some clarification from MDG as I think there may be a new bug here…

It used to be the case (earlier this year, not sure which version) that the reactive Meteor.userId() would change to null and so we could make our UI respond nicely when logged out remotely.

This is no longer the case. And Accounts.onLogout() callback definitely does not get invoked either.

I think the DDP connection simply gets dropped. Which is of no help as an interruption of client/server connectivity is a very different thing.

Essentially Accounts.logoutOtherClients() is rendered unusable (I am having to take it out of my UI as a management feature, as the experience on the other user instances is horrible).

Can anyone shed some light on this?

Additional note:

The same behaviour is shown when I have two tabs open on the application in the same browser (i.e. same session). Logout out on one tab and the other disconnects (the logged out tab keeps its connection fine, allowing anonymous use of site).

Network log on the remaining (disconnected) tab shows a GET request with info?cb=<10 digit random string> followed by a web socket call status 101. No DDP comms happens from there on.

Using Meteor

Can someone try this to check it’s not just me?

I’ve got a clearer picture of what is happening now.

Have 2 tabs in the browser logged into your app. Logout of one and the other retains it’s Meteor.userId() thus thinking it is still logged in. When, for example, subscriptions are requested in this state, I can see that the server has this.userId==null. The DDP connection is fine. If I login again (maybe with a different user) the other tab gets its act together and reflects that new login.

So the only issue is that on logout from one tab other client tabs still think they are logged in but the server side knows otherwise!

I can’t really see how my application code could be causing this bad behaviour. Then again …

If it is a problem that others experience then I think it is a serious problem.

I am having the same type of problem. If I have only one tab open, logging in works fine. If I two tabs open and I log in, both tabs get logged in then it seems reactivity causes the two tabs to start fighting each other and after a time and multiple refreshes, both tabs get logged out.

I’m using console.log in the callback of logoutOtherClients() and it shows it being fired multiple times. Also, when I comment out the logoutOtherClients() call, the problem disappears so it seems like it is at least partially responsible for this problem.

1 Like

Just tested logging out of one Chrome browser tab while being logged in to two tabs. Second tab also correctly logs out and shows UI that reflects the logout. Running Meteor

Also, we are using logoutOtherClients() in our app to logout other sessions. This does not work across browser tabs, which is correct behavior.

OK, great, thanks very much for checking that - must be something to do with my set up and so will have investigate further.


As is so often the case, this was all my fault, sigh. I had wrapped a publication like so:

Meteor.publish('my.publication', function() {
    if (this.userId) {
       // publish stuff

On logging out, this seems to have a rather catastrophic side effect whose symptom was exactly as described above: The Meteor.userId() never lost its value in sessions other than the one from which the logout occurred.

Took me ages to chase that one down! Incidentally putting a

    } else this.ready();

made no difference.

So if by any chance anyone is thinking of doing the same … don’t (there was actually no good reason for me to have put that if statement in anyways).

Oh well

1 Like

Same exact problem. Did you solve this? The down side of removing logoutOtherClients is you don’t get to invalidate other sessions.

My problem was solved as per my PostScript post…