I would like to know if I need to use this.unblock()
inside a Meteor method if the method is already non-blocking.
Here is a contrived example:
Meteor.methods({
myMethod() {
this.unblock();
someAPIWrapper(params, function (err, res) {
// do something with res asynchronously
});
}
});
myMethod
makes an HTTP call using some node.js wrapper for a third party API. It is asynchronous.
In this case, is there a performance gain by using this.unblock()
?
Basically no.
this.unblock()
allows the execution of ordered method calls from a single client to continue within a new fiber because the current one is blocked by a synchronous operation.
So as long as your method body does not do any work that blocks the current fiber, you don't need to unblock it explicitly. In fact, it may even cause its own overhead due to creation of new unnecessary fibers.