Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

middleware_stack.js:31 Uncaught Error: Handler with name 'route' already exists. Iron router Meteor

My code was working fine until last night and suddenly I am getting this error and routes are not working at all.

middleware_stack.js:31Uncaught Error: Handler with name 'route' already exists.

for simple routes like this:

Router.route('/admin/dashboard', {
   template:"adminDashboard"
});

Router.route('/admin/create/table', {
  template:"create_table"
});

I cannot figure out the error, I have checked all the routes. Have anyone else faced this error?

like image 779
Bipin Bhandari Avatar asked Mar 16 '16 09:03

Bipin Bhandari


2 Answers

This is a known issue. The problem occurs with recent versions of Google Chrome and Microsoft Edge (edit: also Firefox now).

It has been fixed by a recent iron router update, it should be fixed by meteor update iron:middleware-stack.

Edit: If the middleware-stack package rolls back when you restart the server, check @bigsan's comment

like image 187
Julien Avatar answered Oct 15 '22 09:10

Julien


Edit: this issue was fixed in iron:middleware-stack 1.1.0 .

I have the same problem. Weirdly, I have this problem on Chrome 51 but not on Chrome 46. I guess this has to do with updates in the javascript engine, and I'll post here if I figure out what exactly.

In the meantime, the workaround I used was to explicitly add names to the routes. It doesn't matter what they are, they just have to be declared, otherwise iron-router think the name of the route is "route." So your code would become:

Router.route('/admin/dashboard', {
   name: "Boaty_McBoatface",
   template:"adminDashboard"
});

Router.route('/admin/create/table', {
   name: "Guacamole",
   template:"create_table"
});
like image 39
foobarbecue Avatar answered Oct 15 '22 10:10

foobarbecue