2

When I have active Meteor login token and perform a DB drop with meteor reset, app page freezes badly on reload. It feels like the page keeps loading, though there is nothing on the page I can interact with. Browser console hangs as well. Tested on Chrome and Firefox, facing same behavior. But when I try to remove cache for the app domain (through browser settings, as dev tools are unconscious), everything becomes okay, I get redirected to a login page (as provided in my route config) and browser console has the following message: You've been logged out by the server. Please log in again. This is my Iron Router global onBeforeAction hook:

Router.onBeforeAction(function () {

document.documentElement.className = 'gt-ie8 gt-ie9';

var currentUser = Meteor.user(),
    currentRoute = this.route.getName(),
    routeOptions = {},
    userRoles,
    userCompany, userTeam,
    allowedRoutes;

// prevent not logged in user from visiting the app
// console.log(this.next);
if (!currentUser) {
  this.redirect('login');
  // return;
} else {

  userRoles = currentUser.roles;

  userRoles = userRoles.length ? userRoles : ['member'];
  userCompany = currentUser.companyId || null;
  userTeam = currentUser.teamId || null;

  // get current user allowed routes (for highest role)
  allowedRoutes = _.filter(SW.roles, function (appRoute, index) {
    return userRoles.indexOf(index) > -1;
  });
  allowedRoutes = allowedRoutes && allowedRoutes.length ? allowedRoutes[0].routes : [];

  // if not all routes are allowed
  if (allowedRoutes.indexOf('*') === -1) {
    // restrict if route is not allowed
    if (!allowedRoutes.length || allowedRoutes.indexOf(currentRoute) === -1) {
      this.redirect('member.self');
    }
  }

}

this.next();

}, {
  except: ['enroll', 'login', 'logout']
});

I need to mention as well that this is very weird slippy issue that happens on production server far more often than when performing local testing.

2
  • You're using meteor reset on a production server? The problem is that this shuts down the Meteor server, disconnecting any users. If you update the code and let Meteor hot-reload as normal, this shouldn't happen unless the hot-reload times out.
    – sbking
    Commented Dec 10, 2014 at 23:18
  • @sbking I'm using meteor reset locally, and it happens time of the time in that case. Though on production there is a script that drops database after deployment, and it tends to appear more often there. After some changes I have to perform database drop, and this where the issue comes out.
    – evenfrost
    Commented Dec 11, 2014 at 7:13

1 Answer 1

0

The issue seems to be gone with the latest Meteor update (1.0.2.1). Though, it may be because of this issue with Fast Render (fixed in 2.1.0), which I'm using on my project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.