Is it valid to write async meteor methods?

Simple question: I wonder if it is valid to write async meteor methods or does meteor require them to be synchronous? And are there any limitations to it?

Let me explain. In my application I want to execute a binary which take a long time to complete. My idea was to start the child process and then setup an event handler to handle the result when the execution is done. I could thus return from the method immediately after I did start the child process.

BUT I have noticed some strange issues after doing this which makes Meteor to never send back the “updated” DDP message. This has made me believe that perhaps Meteor requires asynchronous methods.

The child process cannot contribute to the result of the method since it will execute after the method has returned.

I think you would have to create a Mongo collection to store the results of the child process. The server method can return to the client the _id of the new document. Then either the client can subscribe to that collection to get the data as soon as it’s available, or regularly poll a server method to fetch the result.

What if the client disconnects before the child process is complete? You might have to store the _id in the record for that user so they can get the result when they reconnect, or reference the user’s own id in the result collection.

For long-running jobs I prefer to use Meteor Job Collection…

While it may seem “heavy” it is easy to use once you get the hang of it and can be the central place for any “expensive” server-based work that requires async operation (think things like large reports and such).