Method stub took too long and could cause unexpected problems

Hello,
I am trying to update to 3.0.

I have quite a lot of this message in my console on the client :

Method stub (my-method-name) took too long and could cause unexpected problems

There is a link to this page : GitHub - zodern/fix-async-stubs: Package to remove limitations with async stubs in Meteor

And this page is also mentionning this : Migrating to Meteor 2.8 | Meteor Guide

I read both this pages carefully but I don’t understand what I am doing wrong.

I use blaze and in the onCreated of the template, I perform may calls in parrallel to methods like this :

Template.myTemplate.onCreated(function() {
  const instance = this;

  this.myBookmarks = new ReactiveVar([]);
  Meteor.callAsync('bookmarks/get')
        .then(function (myBookmarks) {
          instance.myBookmarks.set(myBookmarks)
        })
        .catch(function(err) {
          console.error(err);
        });

 this.myStuff = new ReactiveVar([]);
  Meteor.callAsync('stuff/get')
        .then(function (myStuff) {
          instance.myStuff.set(myStuff)
        })
        .catch(function(err) {
          console.error(err);
        });

});

Do you know what the problem is ?

1 Like

I think there are issues with Meteor.callAsync in 3.0 that are being addressed. See this PR: Fix an issue with methods interacting with unblocking mechanisms by nachocodoner · Pull Request #13055 · meteor/meteor · GitHub

1 Like

Thanks for pointing out this PR.
In my case, methods are called from the client but are only defined on the server (I do not use client methods)

Yep, I see the same. I made an issue for it a while back: [Meteor 3] Server-only Method displays "Method stub took too long" warning in browser console when using Meteor.callAsync · Issue #12999 · meteor/meteor · GitHub

I think the fix also affects the scenario being the method server-only, but I will double check.

Thanks for the report

Thanks a lot.
Let me know if you want me to test something

1 Like

I was able to reproduce this in the simple-todo-app very easily :

In this case my server methods does not interact with DB but I see the warning

Even with one single method, this happens :

Why using Meteor.callAsync if you dont need a stub ? Meteor.call with callback seems to work with 3.0 client side

I have no idea what a stub is…
In our code on the client, we have a lot of Meteor.call with callbacks and Meteor.callAsync with the then/catch syntax. We convert the Meteor.call to Meteor.callAsync progressively to match the new syntax of v3.

EDIT : Ok I just read again the documentation. Stub are methods defined on the client. No we don’t use Method stub. We only use methods defined on the server.