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.
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.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.