iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

My publications rerun every 10 seconds #1501

Closed dpatte closed 8 years ago

dpatte commented 8 years ago

This only occurs on a system using polling instead of oplog, and only on pages that use onBeforeAction such as the following:

Router.onBeforeAction(requireLoginRt, {only: 'dealList'});

requireLoginRt looks like this:

var requireLoginRt = function() {
if (!!Meteor.user()) this.next(); // logged in else if (Meteor.loggingIn()) this.render(this.loadingTemplate); // logging in (loading) else this.render('accessDenied'); // not logged in (access denied) }

chrisbutler commented 8 years ago

@dpatte you should check for Meteor.userId() rather than the full user object, because if you have code somewhere else that modifies the user, it will cause this function to re-run due to Meteor's reactivity