执行流星重置时,登录用户的应用程序页面冻结

App page freezes for logged in user when performing meteor reset

本文关键字:用户 应用程序 冻结 登录 流星 执行流 执行      更新时间:2023-09-26

当我有活动的 Meteor 登录令牌并使用 meteor reset 执行数据库删除时,应用程序页面在重新加载时严重冻结。感觉页面一直在加载,尽管页面上没有任何内容可以与我交互。浏览器控制台也挂起。在Chrome和Firefox上测试,面临相同的行为。但是当我尝试删除应用程序域的缓存时(通过浏览器设置,因为开发工具是无意识的(,一切都变得正常,我被重定向到登录页面(如我的路由配置中提供(,浏览器控制台显示以下消息:You've been logged out by the server. Please log in again。这是我的铁路由器全局之前操作钩子:

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']
});

我还需要提到,这是一个非常奇怪的滑溜问题,在生产服务器上发生的频率远远高于执行本地测试时。

最新的 Meteor 更新 (1.0.2.1( 似乎已经消失了这个问题。不过,这可能是因为我在项目中使用的快速渲染(在 2.1.0 中修复(的这个问题。

相关文章: