ember-cli-copyable icon indicating copy to clipboard operation
ember-cli-copyable copied to clipboard

Deep copy browser stuck

Open spuyet opened this issue 8 years ago • 3 comments

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 ?

spuyet avatar Mar 25 '16 13:03 spuyet

@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

Blackening999 avatar Apr 07 '16 19:04 Blackening999

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?

stevesims avatar Jul 15 '16 15:07 stevesims

Same here, +1 to #17 merge

Cottonwoods avatar Aug 11 '16 18:08 Cottonwoods