Meteor 对象不是onBeforeAction钩子处iron router routes中的函数;这是什么

Meteor 对象不是onBeforeAction钩子处iron router routes中的函数;这是什么,meteor,iron-router,Meteor,Iron Router,我正在运行iron router 1.0.7,我的onBeforeActionhook导致异常。以下是堆栈跟踪: Exception in callback of async function: TypeError: object is not a function at Router.onBeforeAction.except (http://localhost:3000/lib/router.js?ebfe803416134e7c5b16265486b3998532289c58:45

我正在运行iron router 1.0.7,我的
onBeforeAction
hook导致异常。以下是堆栈跟踪:

Exception in callback of async function: TypeError: object is not a function
    at Router.onBeforeAction.except (http://localhost:3000/lib/router.js?ebfe803416134e7c5b16265486b3998532289c58:45:8)
    at http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1199:36
    at _.extend.withValue (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:955:17)
    at Router.addHook.hookWithOptions (http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1198:27)
    at boundNext (http://localhost:3000/packages/iron_middleware-stack.js?0e0f6983a838a6516556b08e62894f89720e2c44:424:31)
    at Meteor.bindEnvironment (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:983:22)
    at Router.onBeforeAction.only (http://localhost:3000/lib/router.js?ebfe803416134e7c5b16265486b3998532289c58:28:12)
    at http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1199:36
    at _.extend.withValue (http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:955:17)
    at Router.addHook.hookWithOptions (http://localhost:3000/packages/iron_router.js?a427868585af16bb88b7c9996b2449aebb8dbf51:1198:27)
以下是引用的钩子:

Router.onBeforeAction(function () {
    //check if it's a logged in user
    if (!Meteor.userId()) {
      //if they aren't redirect them to login
      this.render('login');
    } else {
      //if they are let them through
      this.next();
    }
  },
  //the routes we want this if logged in check for
  {only: ['profile', 'logout', 'users']
});

// Redirects users to the survey until they have answered all the questions
Router.onBeforeAction(function() {
  Meteor.subscribe('questions');
  var answered = getUserAnswers();
  var unanswered = Questions.find({ _id: { $nin: answered } }, {sort: {priority: 1}}).count();
  if (unanswered && Roles.userIsInRole(Meteor.user(), 'manage-users')) {
    this.next();
  } else if (unanswered) {
    this.redirect('survey');
  }
  this.next();
},
  {except: ['survey', 'passwordReset', 'logout', 'settings', 'login']});

这似乎是导致异常的最后一个
this.next()
(这是跟踪的第一行中引用的行),但我不知道为什么。如果我在DevTools中为它设置一个断点,它会正常运行两次。然后,在第三站,
next
未定义。知道为什么会这样吗?尽管例外,路由看起来仍然正常工作。

我不知道为什么NeXT会变得不明确,但是考虑Waist-Bug中的子ScIsILIN,或者在订阅答案/问题之前检查订阅是否准备好了。如何在钩子上执行waitOn阻塞?我想我只能在路由上这样做。你可以在路由器对象上定义全局onwait过滤器。我不确定。做这些事情肯定有多种方法。我个人尽量避免订阅任何地方,除了onwait或模板本身。您确定except不适用于全局OnWaitis吗?在不使用ifs的情况下绕过它就是创建从RouteControl继承的新RouteControl,所以性能在这里不是问题。关键在于哪个解决方案更干净、更易于维护。