Calling a method from templates onDestroyed event

Methods called from onDestroyed event are not executed on the server and returning undefined result to callback on client. If I call same method from any other event or helper there is no problem.

I just tested this in a project of mine and it works as I would expect. Can you share some code?

  var instance = this;'onDestroyed',, function(err,res){
    console.log(`onRestroyed ${res}`, err);
    "test.Destroy": function(param){
        console.log('testDestroy param:', param);
        return "1";        
Template.ProductFamilies_SubList_Template.onDestroyed(function() {
    console.log("ProductFamilies_SubList_Template.onDestroyed");"test.Destroy", "001", function(error, result){
            console.error("ProductFamilies_SubList_Template error:", error);
            console.log("ProductFamilies_SubList_Template result:", result);

Log prints immediately on the client side;

ProductFamilies.templates.js:302 ProductFamilies_SubList_Template result: undefined

But nothing at all on the server.

Is your method defined on both, server and client, or only on the server?

Only on the server .

Hmm. Try what you get without the sleep on the server

Same result, method is never called.

That is odd, since my test verified that it should and does work. Is there any other code that might be interfering? Can you call the method outside of onDestroyed?

I implemented my requirement in a different way without depending onDestroyed. But it is quite strange, most of the time it doesn’t work. Sometimes server method is called as expected. Very unreliable. I tried also with an empty project.