I have a client-server method that looks like this:
Meteor.methods({
removeUser: function () {
if (this.userId)
Meteor.users.remove(this.userId);
}
});
When I call this method from the client, it is executed once on client and twice on server (with this.userId to null the second time).
I have read things about Meteor methods not being idempotent and possibly called several times. But why systematically in this case ?
Just so we know it isnât an issue with how youâre calling the method, when you run it from browser console: Meteor.call('removeUser') you see it happen twice on the server? I am guessing in testing youâve put something inside the method to log that its being run more than once.
Meteor methods in my experience are not idempotent unless you explicitly design them to be.
I use methods all the time and have never had the experience youâre describing.
The method is called from an event handler (âclick buttonâ), with no autorun. I get the same behavior when calling it from the console.
It has to relate to what I am doing in the method: deleting the currently logged-in user.
After further investigation, I noticed this problem occurs only if deleting a user whose accounts has been merged with accounts-meld. Deleting a ânormalâ user causes no issue (method called once).