mardi 1 mars 2016

EmberJS transition error route undefined when user changes URL manually

I've been trying to debug this problem for a while and can't seem to find out why my application crashes. I have the following router:

Router.map(function() {
  this.route('posts', {path: 'post/:id'});
});

and the corresponding route:

export default Ember.Route.extend({
  model(params) {
    return this.store.findRecord('posts', params.id);    
  },
});

if the user goes to localhost:4200/post/1, all is fine. But if the user manually changes the route to localhost:4200/post/1, I get the following stack trace:

TypeError: Cannot set property 'endTime' of undefined
    at TransitionData.routeFinishedSetup (transition-data.js:50)
    at routeWillRender (ember-perf.js:124)
    at renderTemplate (route.js:14)
    at superWrapper [as renderTemplate] (ember.debug.js:21573)
    at _emberRuntimeSystemObject.default.extend.setup (ember.debug.js:26400)
    at Object.callHook (ember.debug.js:50998)
    at handlerEnteredOrUpdated (ember.debug.js:49778)
    at setupContexts (ember.debug.js:49742)
    at finalizeTransition (ember.debug.js:49924)
    at ember.debug.js:49359

I tried looking at the code in routeFinishedSetup and it seems that this.routes is an empty array.

Through some debugging, I found that this error does not happen anymore IF i change the model function such that it does not call the store. For example, if I implement a custom promise here it works fine. How can I debug this issue further or if anyone can propose a solution? Thanks!




Aucun commentaire:

Enregistrer un commentaire