Router level subscription does not fire immediately



Lately, I’ve been adding more logic to router based subscription (in iron router’s waitOn, along with some amount of logic in the publish function on the server) Each page has it’s own subscription parameters that are derived by the publish function based on the current URL I send from the client to the server when that particular page is navigated to.

Intermittently I’ve noticed that upon landing on a new route, the subscription function (waitOn) does not fire immediately. It takes a good 15s before the subscription function executes and the documents are available on the client. It is almost as if the router never immediately realized that the route has changed, although the right page is rendered. This “glitch” is immediately rectified when I hard refresh the entire page via the browser. I’m not sure why there is a delay in calling the subscription function.

Note: My collections are not heavy. They hardly have 100 documents. So this is not something that has got to do with the count of records being sent from the server. The issue is something even before this, since the docs are sent over immediately after the subscription is triggered.

I’m trying to understand why this happens intermittently, on random routes.

Router.route('/dashboard', {
    name: 'dashboard',
    title: 'Home',
    layoutTemplate: 'loggedInIndex',
    waitOn: function() {
            return [
        else {

My publish function basically takes in the url that is passed and returns the collection based on the URL.



I’ve never used iron router, so take my comments with a pinch of salt!

One of the known issues with IR is that reactivity can become excessive in some use cases. If that’s happening here, it should manifest itself as high CPU. So, you could start the Chrome task manager, or the web inspector, and check what happens during this delay.


I’m just adding to what is already existing on IR. I don’t mind moving it all to template level subs, probably will take half a day to roll it out on every template.

I shall take a look at the console when I notice this. Will get back on this thread with some findings.