lazybensch / ember-cli-copyable

Deeply copies your records including their relations. The mixin is smart enough to resolve not loaded relations and is configurable to what should be shallow/deeply copied or excluded entirely.
MIT License
25 stars 17 forks source link

Deep copy browser stuck #19

Open spuyet opened 8 years ago

spuyet commented 8 years ago

Hi,

My browser becomes stuck with 100% CPU usage on object copy:

This is my action:

 actions: {
    selectSurvey(id, component) {
      let store = this.store;
      let campaign = this.get('model');
      campaign.get('survey').then(function(survey) {
        if (survey)
          survey.destroyRecord();
        store.find('survey', id).then(function(survey) {
          survey.copy().then(function(copy) {});
        });
      });
    },
 }

The survey model is copyable and has many questions (copyable too) with many answers (copyable again). Maybe an infinite loop in deep copy ?

The problem occurred only on survey with questions. Copy for a survey without questions works fine.

Ember-cli: 2.3.0 Ember-cli-copyable: 0.9.6

Any idea ?

Blackening999 commented 8 years ago

@spuyet I had the similar issue, it's obviously - infinite loop cycle.

You might have relation in your Question or Answer model to survey or to it's predcessor in hierarchical chain: Question has belongsTo relation to Survey

or

Answer has relation to either Question or Survey

stevesims commented 8 years ago

I think I'm suffering from this too. To use the example that @Blackening999 is suggesting, in my model I have a Survey model with questions: hasMany(), and a Question model with survey: belongsTo(). Attempting to clone a Survey instance results in an infinite loop.

It seems that PR #17 may be the solution - could it please get merged in?

Cottonwoods commented 8 years ago

Same here, +1 to #17 merge