Search code examples
meteorupdatesiron-router

Error after update to Meteor 1.3 - Handler with name 'onBeforeAction' already exists


My app has been working until I've updated it to Meteor 1.3. Now I get this error:

Exception in callback of async function: Error: Handler with name 'onBeforeAction' already exists.
at MiddlewareStack._create (http://localhost:3000/packages/iron_middleware-stack.js?hash=8a2aa73e86a32698fb9f60cea452e0ecb2e72b7f:190:13)
at MiddlewareStack.push (http://localhost:3000/packages/iron_middleware-stack.js?hash=8a2aa73e86a32698fb9f60cea452e0ecb2e72b7f:206:22)
at http://localhost:3000/packages/iron_middleware-stack.js?hash=8a2aa73e86a32698fb9f60cea452e0ecb2e72b7f:224:12
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=8de51f9d86e95ae2ffee15a8db324a1decccba3e:139:11)
at MiddlewareStack.append (http://localhost:3000/packages/iron_middleware-stack.js?hash=8a2aa73e86a32698fb9f60cea452e0ecb2e72b7f:220:5)
at http://localhost:3000/packages/iron_middleware-stack.js?hash=8a2aa73e86a32698fb9f60cea452e0ecb2e72b7f:226:19
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=8de51f9d86e95ae2ffee15a8db324a1decccba3e:139:11)
at MiddlewareStack.append (http://localhost:3000/packages/iron_middleware-stack.js?hash=8a2aa73e86a32698fb9f60cea452e0ecb2e72b7f:220:5)

The only places where I use onBeforeAction is in my iron-router route controllers. They're all in the same router.js file.

I define several route controllers, first an ApplicationController that extends RouteController and then various controllers that extend ApplicationController.

ApplicationController = RouteController.extend({
  onBeforeAction: function() {
    //some code
    this.next();
  }
});

SomeController = ApplicationController.extend({
  onBeforeAction: function() {
    //some code
    this.next();
  }
});

From the error message I'm unable to work out what is wrong or where to look for the problem.

Versions of packages mentioned in error message are:

iron:router@1.0.12
iron:middleware-stack@1.0.11
underscore@1.0.6

I'd really appreciate some pointers in the right direction.


Solution

  • First of i would highly recommend you if it is possible to change your router and switch to FlowRouter. This is the official Meteor router by now, as stated here : Meteor Guide

    Try this : meteor update iron:middleware-stack.

    It seems that your problem is related to this issue and it has been fixed in 1.1.0 version.