Pub/Sub Not Working After User Login


Hi Forum,

I have an issue with what should be a simple pub/sub. The pub/sub works fine before a user logs in; sending 5 small documents to the client in a couple seconds.

However, immediately after a user logs in, the data is removed from the client, and the publication is slow to rerun, hangs and never returns, or eventually returns but only after several minutes.

I have no idea why the user’s login status is impacting this. But I verified it by logging the user out and the publication works quickly again. The publication doesn’t depend on any user data though, so I’m confused about what the connection is between the user’s login status and the publication.

I’m using accounts-base, accounts-password, and iron-router. Here is the relevant code:

// Server Publish 
Meteor.publish("module_instance", function (app_id) {
    return = ModuleInstance.find({'app_id':app_id});

Iron Router global configuration subscribes to the publication. The getAppId() method just parses the URL for an ID string and returns it. I’ve confirmed its always returning the correct value.

// Global router configuration                                                                                                                                                  
    'loadingTemplate' : 'loading',
    'notFoundTemplate': 'loading',
    'layoutTemplate' : 'fullscreen_layout',
    'waitOn' : function(){
        return Meteor.subscribe('module_instance', getAppId());
    'onRun' : function(){;

Does anyone have any thoughts on what I’m doing wrong?


I don’t know what causes the problem. Maybe using meteor dev tool plugin on google chrome browser could help you debug.


On further investigation, it seems like there is a problem with Meteor.loginWithPassword(). It’s taking a really long time to respond then the entire server slows down after it returns. Trying to figure out why that might be. I do have a lot of user accounts 300k+. Maybe that’s causing the login to slow down.

1 Like

I would start by checking how much data is being published. Not that this is definitely the cause, but I’ve seen in the past where an app publishing a few hundred docs from a publication can stall the app for for a few seconds and I’m sure the more you publish, the more affect it has. I personally try to never publish more than about 50 docs from any one publish and use skip and limit to paginate as necessary.

1 Like