ember-data-model-fragments icon indicating copy to clipboard operation
ember-data-model-fragments copied to clipboard

Observer causing Maximum call stack size exceeded with nested fragments

Open shidel-dev opened this issue 9 years ago • 12 comments

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)

shidel-dev avatar Mar 31 '16 16:03 shidel-dev

seems similar to https://github.com/lytics/ember-data-model-fragments/pull/60 and https://github.com/lytics/ember-data-model-fragments/pull/54

shidel-dev avatar Mar 31 '16 18:03 shidel-dev

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.

shidel-dev avatar Mar 31 '16 21:03 shidel-dev

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.

slindberg avatar Apr 01 '16 05:04 slindberg

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:

  1. Create a new fragment on an existing record (in this case fragment not fragmentArray).
  2. Save the record.
  3. Update an attribute on the fragment before the record has finished saving.
  4. 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.

workmanw avatar Apr 01 '16 17:04 workmanw

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.

DingoEatingFuzz avatar Nov 10 '16 01:11 DingoEatingFuzz

Cool thanks for the reproduction! I'll give it a look over when I get some free time

jakesjews avatar Nov 10 '16 01:11 jakesjews

whats the status of the issue right now

Amerr avatar Oct 05 '17 12:10 Amerr

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.

jakesjews avatar Oct 05 '17 13:10 jakesjews

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.

Amerr avatar Oct 05 '17 23:10 Amerr

Any updates. Is this fixed?

aandis avatar Oct 21 '18 18:10 aandis

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 avatar Oct 22 '18 10:10 JosephHalter

@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.

aandis avatar Oct 22 '18 19:10 aandis