ember-data-model-fragments
ember-data-model-fragments copied to clipboard
"Cannot read property 'didChange' of undefined" when upgrading from 1.13.1 to 1.13.2
After updating from 1.13.1 to 1.13.2 (that changed setProperties to internalModel#setupData) we've started getting Cannot read property 'didChange' of undefined
when saving a record that has nested fragments.
Trace:
TypeError: Cannot read property 'didChange' of undefined
at chainsDidChange (ember.debug.js:20537)
at propertyDidChange (ember.debug.js:20417)
at iterDeps (ember.debug.js:20504)
at dependentKeysDidChange (ember.debug.js:20460)
at Object.propertyDidChange (ember.debug.js:20414)
at exports.default._emberMetalMixin.Mixin.create.propertyDidChange (ember.debug.js:36766)
at exports.default._emberMetalMixin.Mixin.create.notifyPropertyChange (ember.debug.js:36780)
at Ember.Object.extend._notifyProperties (model.js:564)
at InternalModel.ember$data$lib$system$model$internal$model$$InternalModel.setupData (internal-model.js:196)
at model$fragments$lib$fragments$fragment$$setFragmentData (fragment.js:191)
Setup:
// Setup is something like this:
// model.js
export default DS.Model.extend({
sections: MF.fragmentArray('section')
)};
// section.js
export default MF.Fragment.extend({
subSections: MF.fragmentArray('sub-section')
});
// sub-section.js
export default MF.Fragment.extend({
...
});
Steps to reproduce:
- load a model with nested fragments into the store
- save the model
- TypeError
note: this only seems to happen if:
- the nested fragment (
sub-section
) is present - the nested fragment was not changed (if it's dirty the error is not triggered)
ember: 1.13.10 ember data: 1.13.15
I'll try to find a way to reproduce this outside of our app or write a failing test when I have some more time.
Thanks for reporting, I'm surprised there's a failure so deep in the ember observer internals. I'll try to make time for this soon, but of course failing tests always help out immensely.
I've narrowed it down to an observer in our app that tracks the embedded fragments (i.e. '[email protected]'
), the error happens even if the observer has an empty body.
That probably explains why the trace shows ember observer internals.
No luck with reproducing in a test, yet
Running into this too with Model Fragments 0.4.1 and Ember Data 1.13.13.
Trying to create a minimum test case, but here's where it's failing:
for (i = 0, l = nodes.length; i < l; i++) {
nodes[i].didChange(events);
}
nodes[1]
is undefined
, which causes the error. So it looks like didChange
on nodes[0]
is removing the other element from the array, causing the out of bounds access.
Since my last update in January, my bandwidth for this project has been cut way back. Since this issue is only affecting you two, and my initial efforts to track it down were fruitless, I'm going to have to put this on the back-burner indefinitely. If either of you can create a twiddle or repository to reproduce this reliably, I'll take another look. It's quite possible that this is simply an issue with Ember itself, and updating to 2.x will solve it for you. Also note, v0.4.x is no longer supported.