ember-data-model-fragments: [Bug Ember 3.15.0+] Creating a tracked model with a fragment array throws back-tracking assertions
I’m currently trying to upgrade our app from ember-source 3.14.x to 3.15.x and I’ve found a blocker which is preventing our upgrade.
From ember-source 3.15.0-beta.4 it appears that tracked models which have properties using fragmentArray
will throw a backtracking rerender assertion causing things to blow up.
There are two suspect commits in ember-source where this was introduced.
emberjs/ember.js#17834 [BUGFIX] Prevents autotracking ArrayProxy creation emberjs/ember.js#18554 [BREAKING BUGFIX] Adds autotracking transaction
I’ve created an extremely simplified test case in https://github.com/lytics/ember-data-model-fragments/pull/358 and it throws the following assertion:
Error: Assertion Failed: You attempted to update `[]` on `Array`, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.
`[]` was first used:
- While rendering:
application
index
my-component
this.record
Stack trace for the first usage:
at get (http://localhost:7357/assets/vendor.js:14851:32)
at Class._addArrangedContentArrayObserver (http://localhost:7357/assets/vendor.js:28971:44)
at Class.init (http://localhost:7357/assets/vendor.js:28831:12)
at Class.init (http://localhost:7357/assets/vendor.js:87960:12)
at Class.superWrapper [as init] (http://localhost:7357/assets/vendor.js:30845:22)
at initialize (http://localhost:7357/assets/vendor.js:29137:9)
at Function.create (http://localhost:7357/assets/vendor.js:29720:9)
at createFragmentArray (http://localhost:7357/assets/vendor.js:88297:32)
Stack trace for the update:
at dirtyTagFor (http://localhost:7357/assets/vendor.js:55641:11)
at markObjectAsDirty (http://localhost:7357/assets/vendor.js:14006:32)
at notifyPropertyChange (http://localhost:7357/assets/vendor.js:14043:5)
at arrayContentDidChange (http://localhost:7357/assets/vendor.js:14144:7)
at replaceInNativeArray (http://localhost:7357/assets/vendor.js:14210:5)
at Array.replace (http://localhost:7357/assets/vendor.js:27255:39)
at Class.setupData (http://localhost:7357/assets/vendor.js:88000:15)
The problem appears to happen in the following lines, specifically 298 (where the array is created) and 300 (where the array is updated) https://github.com/lytics/ember-data-model-fragments/blob/c00e2b1a40b296e0c0c3c21ca0f463d12888cd27/addon/attributes.js#L298-L300
The array is first set up in createArray
at
the array is modified a second time in
While in my test reproduction I am specifically marking the property as @tracked
@tracked selectedRecord = this.store.createRecord('my-model', { fragments: [] });
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (8 by maintainers)
Fixed in v6.0.1
@GuillaumeCisco we’re currently moving ownership to ember-adopted-addons
Has this issue been resolved? I usually get this kind of error with ember fragment array too 😕
@patocallaghan I’ve been sick the last few days but I can chat more after I’m better. I think it’s ok to make some breaking changes in a new major version release if need be. I took over maintenance on this after the original author moved on so a lot of the historical usage is unknown to me as well.