The annoying part- The error is only thrown when you navigate to the affected route!
This means you need to test your app by going to every route!
Or, you can try understand the problem, and see if the issue applies to you-
// This example works in Chrome/Firefox, but fails in Edge.
var A = RouteController.extend({
// In Edge this function gets the name `onBeforeAction`, even though it's "anonymous"
// Where Chrome/Firefox, the name == ""
onBeforeAction: function() {
console.warn('A');
this.next();
}
});
var B = A.extend({
// Again, this function also gets the name `onBeforeAction`
onBeforeAction: function() {
console.warn('B');
this.next();
}
});
Router.route('extendTest', {
controller: B
});
// Only when you `go` you'll get the error:
// "Handler with name 'onBeforeAction' already exists."
// Because MiddleWareStack is fussy about having uniquely named functions
Router.go('extendTest');
The Fix?
Change your code to ensure they stay “anonymous” functions.
// By defining it outside an object literal, it remains anonymous
var onBeforeAction = function(){}
console.assert(onBeforeAction.name == "")
var A = RouteController.extend({
onBeforeAction: [
// By wrapping in an array, we avoid Edge's auto-naming.
function() {
console.warn('A');
this.next();
}
]
});
I found out that in my case I only get this error when testing locally (accessing with http://localhost:3000) and not on my test server (accessing the app with http://myserver.com). Anyone else experiencing this or do you have this behavior all the time?
It seems that in the latest Chrome Canary (v51.0.2670.0) they have moved some features to stable harmony branch (#disable-javascript-harmony-shipping), so disable Latest stable JavaScript features as well.
@miro Mine only crashed online.
Disabling ‘Latest stable Javascript features’ solved it, thanks for the tip.
I don’t have to waste time looking for something wrong in my code