Reload record throws inFlight exception


#1

Recently in our project we added a web-socket service for push records in our store without making polling all time; the integration was very successful :smiley: but we’re having many issues with reloading records that are in root.loaded.updated.inFlight

The problem is that we have to handle the disconnection event of the pusher service, for manage the status of the controllers and keep the data up to date; for do this we have created a handler in our controllers:

App.DashboardController = App.Controller.extend({
   disconnect: function() {
       this.get('model').reload();
   }
});

This works fine the 95% of the cases, but in some scenarios the model is currently refreshing their data, and Ember Data throws an exception:

Attempted to handle event 'reloadRecord' on <App.User:ember1701:3375789> while in state root.loaded.updated.inFlight.

I also read about forcing a transition in the record but this hack doesn’t work for us because at any time we can receive new records via the socket… So guys, what we can do for fix this issue?


#2

This is definitely an issue for me as well. Dirty records are “untouchable” until they became clean again, and that’s something that’s not in your control, so if you pushPayload directly from a push service, you’ll end with forbidden transitions.

I guess ember-data is trying to be conservative and never throw away changes made by the user in the client. But from my point of view, in most scenarios is better to use what’s coming from the backend. As least until we have a better way to deal with conflicts / dirty attributes.

My understanding is that coalescing changes might be something that’s coming in ember-data 1.0. Am I right? Is anybody experiencing the same issues?