1
votes

I understand that ember-data is still in a fairly unstable state. I just would like to confirm that what I'm experiencing is expected behavior or a bug. And hopefully find some manner of work around.

I have an application that functions correctly in every expected way except one. Best I can tell I've traced it back to way the application routes on initial load. If I start the application from a route #/posts or #/post/1 where the id is valid it works fine. Application starts, routes, and loads the model. Any valid route works fine. If I were to use a route with a bad id #/post/1a534b where ember-data will not be able to find an underlying model with that id, the application never routes.

I've enabled LOG_TRANSITIONS on my application and confirmed it never transitions to a route, doesn't error on routing, never even injects my application template into the DOM. This problem is unique to initial load as it seems to wait for the model to load before injecting. This never happens because the promised model doesn't exist.

So is this expected behavior or is something else at play here?

I will say that my application isn't loaded til after dom ready and is pulled down async on dom ready. This shouldn't make a difference as the application runs fine when loaded with a proper route.

In the mean time I'll see if I can get a jsfiddle as an example since I can't use my code directly.

2

2 Answers

1
votes

Unfortunately I believe this is expected behavior at the moment:

https://github.com/emberjs/ember.js/issues/1454

I think there is work being done to address errors and the router in general here:

https://github.com/emberjs/ember.js/pull/2740

0
votes

In the route, transition to another route if the model fails to load.

model(params) {
  return this.store.findRecord('account', params.account_id)
    .catch(()=>{
      this.transitionTo('admin.accounts');
    });
},

I'm currently building an app with Ember 2.10.0