Accounts.onLogin callback fired twice?



I have this in my server code:

Accounts.onLogin(function() {

Sometimes (for example when I log in from the client), the callback is fired once as expected:


But sometimes (for example when I’m logged in already and the server is restarted after the code is changed), the callback is fired twice:


Is this normal? Why is it happening?

Thanks in advance!


I figured it out. When the code changes, the client reloads. So two things happen. First, the server logs back the current user when it restarts, but since the client is also refreshed, a logout + login is triggered from the client (same as closing and reopening the tab). That’s why we see two logins.