문제

I try to migrate an existing Ember.js project to use Ember App Kit and I'm seeing some strange error which I think should not happen here...

If I start the app, everything is initialized, my util classes are up and running and Ajax requests are sent and received - everything seems well. But then I keep getting the same error over and over again:

Uncaught TypeError: Cannot read property 'name' of undefined

If I follow down the StackTrace I came to see that the error occurs in the updatePaths() function of the Router (I commented on the lines where the code starts to fail:

function updatePaths(router) {
  var appController = router.container.lookup('controller:application');

  if (!appController) {
    // appController might not exist when top-level loading/error
    // substates have been entered since ApplicationRoute hasn't
    // actually been entered at that point.
    return;
  }

  var infos = router.router.currentHandlerInfos, // <-- empty Array ([])
      path = Ember.Router._routePath(infos); // <-- empty String ("")

  if (!('currentPath' in appController)) {
    defineProperty(appController, 'currentPath');
  }

  set(appController, 'currentPath', path);

  if (!('currentRouteName' in appController)) {
    defineProperty(appController, 'currentRouteName');
  }

  set(appController, 'currentRouteName', infos[infos.length - 1].name); // throws Uncaught TypeError: Cannot read property 'name' of undefined
}

Here is the StackTrace:

Uncaught TypeError: Cannot read property 'name' of undefined      ember.js:35015
updatePaths                                                       ember.js:35015
Ember.Router.Ember.Object.extend.intermediateTransitionTo         ember.js:34522
(anonymous function)                                              ember.js:34919
forEachRouteAbove                                                 ember.js:34869
defaultActionHandlers.loading                                     ember.js:34915
triggerEvent                                                      ember.js:34983
trigger                                                           ember.js:34116
Transition.trigger                                                ember.js:33952
Ember.Router.Ember.Object.extend._fireLoadingEvent                ember.js:34750
DeferredActionQueues.flush                                        ember.js:5893
Backburner.end                                                    ember.js:5984
Backburner.run                                                    ember.js:6023
Ember.run                                                         ember.js:6426
runInitialize                                                     ember.js:39637
jQuery.Callbacks.fire                                             jquery.js:3063
jQuery.Callbacks.self.fireWith                                    jquery.js:3175
jQuery.extend.ready                                               jquery.js:3381
completed                                                         jquery.js:3397

Also, it seems that the appController is not my instance of the ApplicationController but a generated controller from ember itself and I can't see why (my ApplicationController is defined in app/controllers/application.js...

Does anybody know anything about this behaviour or could show me the right direction to track down this error somehow?

도움이 되었습니까?

해결책

So, I digged deeper into this error and also found an issue over at the GitHub project which is describing what I thought was exactly my problem too.

It turns out that somehow Ember App Kit (or even Ember itself) is swallowing messages/errors thrown by Ember.assert and the like so that I followed the suggestion of Stefan Penner and switched to pause on caught exceptions within my browsers dev tools and I saw that it's not one, but several errors!

Unfortunately all these errors fail silently until the last error cannot be caught anymore which is why every error showed the same Stack Trace...

So, the solution seems to be to be sure to pause on caught exceptions and trace down the error message in Ember.assert()... has anybody else seen the same problem and has some other suggestions or could approve my conclusion?


Screenshot of "pause on caught exceptions" in Chrome Dev Tools:

enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top