I just figure out the hard way that apparently even on the server side, some collection update calls are non-blocking, namely when they are not called through a Meteor.method() definition. What I mean by that is that in the code immediately following the collection.update() call, the data is still the old data, which is a clear sign the db update runs in the background and the update() call returned anyway. I can confirm this by adding a callback function and I find that inside the callback, the data is updated.
I am defining a couple of backend maintenance functions, defined inside a service class and called by shell or cron job. These functions are not and should not be called remotely, so they are not defined as Meteor methods. But they are in a server-only directory (/imports/server/)
Turns out they return immediately and don’t block until the database writes are complete. I verified this.
That is pretty… wrong for my use case. I want them to block. How do I force them to do so?