ember-data-model-fragments
ember-data-model-fragments copied to clipboard
Observer causing Maximum call stack size exceeded with nested fragments
I am using ember data: 2.1.0 ember: 2.1.0 ember model fragments: 2.1.2
I have a model with a fragment that has a fragment. When using a computed alias or an observer, I get a Maximum call stack size exceeded after saving.
here is the full stack track:
RangeError: Maximum call stack size exceeded at GETTER_FUNCTION (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:32662:36) at get (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:33144:27) at _getPath (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:33234:14) at Object.get (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:33149:14) at Descriptor.AliasedProperty_get [as get] (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:26390:36) at Object.get (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:33153:19) at lazyGet (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:27241:38) at Object.ChainNode.value (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:27255:23) at Object.ChainNode.notify (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:27391:32) at Object.ChainWatchers.notify (http://localhost:3000/assets/item-bank/assets/vendor.self-722485c363562af5f2b685ca5777edffe70105b854483e9df6b9b4133333cc09.js?body=1:27128:18)
seems similar to https://github.com/lytics/ember-data-model-fragments/pull/60 and https://github.com/lytics/ember-data-model-fragments/pull/54
I have tried updating to ember 2.2, and ember data 2.2 (like what is present in the bower.json for [email protected]) and this issue continues.
These issues have classically been impossible to diagnose without a failing test or app/twiddle that demonstrates the issue. Can you extract the bare minimum of logic from your app into a test case that reproduces the issue? Thanks for reporting.
Actually digging through our logs I found one case where this happened. It's not really clear exactly what the user did, but I suspect they may have done something like the following:
- Create a new fragment on an existing record (in this case
fragmentnotfragmentArray). - Save the record.
- Update an attribute on the fragment before the record has finished saving.
- When the adapter fulfills it's promise and the save is complete, that's when it looks like this error might have happened.
That's all just a very very rough guess. But I can confirm that we saw this issue with version 2.1 once in production.
While upgrading to Ember 2.2 I came across this in our app as well. I was able to reduce it in a demo app here: https://github.com/DingoEatingFuzz/mf-double-alias-bug
There is a model that has a fragment relationship, and that fragment has a fragment array relationship.
Then there is a component that depends on a property, which is an alias to the fragment array of an alias, and that second alias is an alias of the fragment.
Easier explained with code:
model: null,
firstAlias: Ember.computed.alias('model.someProp'),
secondAlias: Ember.computed.alias('firstAlias.innerFragments'),
someProps: function() {
return this.get('secondAlias').mapBy('prop1');
}.property('[email protected]'),
There's an integration test in that demo app that invokes the bug.
Cool thanks for the reproduction! I'll give it a look over when I get some free time
whats the status of the issue right now
There was a PR merged with a fix but unfortunately it caused a larger issue and had to be reverted. I'm pretty busy at work so I'm not sure when I'll be able to get to it.
Thanks for the update @jakesjews . for now the temporary solution is not use alias on those fragment properties, using normal computed , does the job without throwing error.
Any updates. Is this fixed?
I'm using the latest version of ember-data-model-fragments in a couple of large, high traffic projects with plenty of computed properties and observers all around and I don't have any issue anymore.
@JosephHalter I mostly see this happening while using alias computed properties in my components although I am on an older version. So if it's confirmed that aliases are not a problem for ember-data-model-fragments, this can be considered fixed.